@bymax-one/nest-logger 1.4.29 → 1.4.30

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,60 @@ 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();
863
+ if (matchesPattern(PLAIN, key)) return lowerCase(key);
700
864
  return withLookalikes(
701
- key.normalize("NFKD").toLowerCase().replace(DOTS, ".").replace(INVISIBLE, ""),
865
+ dropInvisible(readDots(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), "."), ""),
702
866
  true
703
867
  );
704
868
  }
705
- if (PLAIN.test(key)) return key.replace(NOT_ASCII_NAME, "").toLowerCase();
706
- return withLookalikes(key.normalize("NFKD").toLowerCase().replace(NOT_NAME, ""), true);
869
+ if (matchesPattern(PLAIN, key)) return lowerCase(dropNotAscii(key, ""));
870
+ return withLookalikes(dropNotName(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), ""), true);
707
871
  }
708
872
  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);
873
+ if (matchesPattern(PLAIN, key)) return lowerCase(dropNotAscii(key, ""));
874
+ return withLookalikes(
875
+ dropNotNameStrict(
876
+ standInSymbols(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), SYMBOL_STAND_IN),
877
+ ""
878
+ ),
879
+ false
880
+ );
711
881
  }
712
882
  function withLookalikes(folded, all) {
713
883
  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);
884
+ for (let at = 0; at < LOOKALIKE_PAIRS.length; at++) {
885
+ const [letter, latin] = LOOKALIKE_PAIRS[at];
886
+ read = replaceAllText(read, letter, latin);
887
+ }
888
+ if (all) {
889
+ for (let at = 0; at < I_LIKE_PAIRS.length; at++) {
890
+ const [letter, latin] = I_LIKE_PAIRS[at];
891
+ read = replaceAllText(read, letter, latin);
892
+ }
893
+ }
716
894
  return read;
717
895
  }
718
896
  var ALNUM = /^[A-Za-z0-9]*$/;
719
897
  function formOf(key) {
720
- return ALNUM.test(key) ? key.toLowerCase() : foldStrict(key);
898
+ return matchesPattern(ALNUM, key) ? lowerCase(key) : foldStrict(key);
721
899
  }
722
900
  var answers = /* @__PURE__ */ new WeakMap();
723
901
  function foldName(key) {
724
902
  return formOf(key);
725
903
  }
726
904
  function foldedNames(names) {
727
- return new Set(Array.from(names, foldName).filter((name) => name !== ""));
905
+ return capturedSet(
906
+ Array.from(names, (name) => replaceAllText(foldName(name), SYMBOL_STAND_IN, "")).filter(
907
+ (name) => name !== ""
908
+ )
909
+ );
728
910
  }
729
911
  var MAX_CANDIDATES = 64;
730
912
  var grouped = /* @__PURE__ */ new WeakMap();
@@ -747,34 +929,45 @@ function groupsOf(names) {
747
929
  }
748
930
  function matchesFolded(names, folded) {
749
931
  if (names.has(folded)) return true;
750
- if (!NON_ASCII.test(folded)) return false;
932
+ if (!matchesPattern(NON_ASCII, folded)) return false;
751
933
  const letters = [...folded];
752
934
  const wide = letters.filter((letter) => !isAscii(letter)).length;
935
+ const stands = letters.filter((letter) => letter === SYMBOL_STAND_IN).length;
753
936
  const { byLength, longest } = groupsOf(names);
754
- if (letters.length > longest) return false;
937
+ if (longest === 0) return false;
938
+ if (stands > longest) return true;
939
+ if (letters.length - stands > longest) return false;
755
940
  const lengths = Array.from(
756
- { length: wide + 1 },
757
- (_, extra) => byLength.get(letters.length + extra) ?? []
941
+ { length: wide + stands + 1 },
942
+ (_, extra) => byLength.get(letters.length - stands + extra) ?? []
758
943
  );
759
944
  if (lengths.reduce((count, same) => count + same.length, 0) > MAX_CANDIDATES) return true;
760
945
  return lengths.some((same) => same.some((name) => matchesName(letters, [...name])));
761
946
  }
762
947
  var isAscii = (letter) => letter < "\x80";
763
948
  function matchesName(letters, name) {
764
- let at = /* @__PURE__ */ new Set([0]);
949
+ const initial = /* @__PURE__ */ new Set();
950
+ setAdd(initial, 0);
951
+ let at = initial;
765
952
  for (const letter of letters) {
766
953
  const next = /* @__PURE__ */ new Set();
767
954
  for (const position of at) {
955
+ if (letter === SYMBOL_STAND_IN) {
956
+ setAdd(next, position);
957
+ setAdd(next, position + 1);
958
+ setAdd(next, position + 2);
959
+ continue;
960
+ }
768
961
  if (isAscii(letter)) {
769
- if (name[position] === letter) next.add(position + 1);
962
+ if (name[position] === letter) setAdd(next, position + 1);
770
963
  continue;
771
964
  }
772
- next.add(position + 1);
773
- next.add(position + 2);
965
+ setAdd(next, position + 1);
966
+ setAdd(next, position + 2);
774
967
  }
775
968
  at = next;
776
969
  }
777
- return at.has(name.length);
970
+ return setHas(at, name.length);
778
971
  }
779
972
  function matchesKey(names, key) {
780
973
  const seen = answers.get(names) ?? /* @__PURE__ */ new Map();
@@ -808,7 +1001,10 @@ function occurrences(stack, message) {
808
1001
  while (matched > 0 && stack[i] !== message[matched]) matched = table[matched - 1];
809
1002
  if (stack[i] === message[matched]) matched += 1;
810
1003
  if (matched === message.length) {
811
- spans.push([i + 1 - message.length, i + 1]);
1004
+ const start = i + 1 - message.length;
1005
+ const last = spans[spans.length - 1];
1006
+ if (last !== void 0 && start < last[1]) last[1] = i + 1;
1007
+ else spans.push([start, i + 1]);
812
1008
  }
813
1009
  }
814
1010
  return spans;
@@ -831,19 +1027,6 @@ function hideMessagesInStack(stack, messages, replacement, limit) {
831
1027
  }
832
1028
  return result + stack.slice(from, Math.max(end, from));
833
1029
  }
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
1030
 
848
1031
  // src/server/utils/censor-stack-header.util.ts
849
1032
  var NAME_SEPARATOR = ": ";
@@ -863,6 +1046,26 @@ function splitCensoredHeader(stack, name, message, censored) {
863
1046
  if (endsHeader(stack, message, 0)) return [censored, stack.slice(message.length)];
864
1047
  return [name === "" ? censored : name + NAME_SEPARATOR + censored, ""];
865
1048
  }
1049
+
1050
+ // src/server/utils/escape-log-text.util.ts
1051
+ var LINE_TERMINATORS = capturedSet(["\r", "\n", "\x85", "\u2028", "\u2029"]);
1052
+ var UNSAFE_IN_SINGLE_LINE = /[\u0000-\u0008\u000A-\u001F\u007F-\u009F\u2028\u2029\p{Cs}]/gu;
1053
+ var UNSAFE_IN_MULTILINE = /[\u0000-\u0008\u000B-\u001F\u007F-\u009F\u2028\u2029\p{Cs}]/gu;
1054
+ function toEscapeSequence(char) {
1055
+ return `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`;
1056
+ }
1057
+ function toSingleLineMessage(text) {
1058
+ return text.replace(
1059
+ UNSAFE_IN_SINGLE_LINE,
1060
+ (char) => LINE_TERMINATORS.has(char) ? "\\n" : toEscapeSequence(char)
1061
+ );
1062
+ }
1063
+ function toBoundedMessage(text) {
1064
+ return cutText(toSingleLineMessage(text));
1065
+ }
1066
+ function escapeControlCharacters(text) {
1067
+ return text.replace(UNSAFE_IN_MULTILINE, toEscapeSequence);
1068
+ }
866
1069
  function isError(value) {
867
1070
  try {
868
1071
  return types.isNativeError(value) || value instanceof Error;
@@ -886,17 +1089,17 @@ var DEFAULT_SAFE_ERROR_FIELDS = [
886
1089
  "schema",
887
1090
  "routine"
888
1091
  ];
889
- var DERIVED_ERROR_FIELDS = /* @__PURE__ */ new Set([
1092
+ var DERIVED_ERROR_FIELDS = capturedSet([
890
1093
  "name",
891
1094
  "message",
892
1095
  "stack",
893
1096
  "cause",
894
1097
  "errors"
895
1098
  ]);
896
- var ALL_OWN_FIELDS = { safe: false, names: /* @__PURE__ */ new Set() };
1099
+ var ALL_OWN_FIELDS = { safe: false, names: capturedSet() };
897
1100
  function createOwnFieldPolicy(mode, extraNames) {
898
1101
  if (mode === "all") return ALL_OWN_FIELDS;
899
- return { safe: true, names: /* @__PURE__ */ new Set([...DEFAULT_SAFE_ERROR_FIELDS, ...extraNames]) };
1102
+ return { safe: true, names: capturedSet([...DEFAULT_SAFE_ERROR_FIELDS, ...extraNames]) };
900
1103
  }
901
1104
  function allowsOwnField(policy, key) {
902
1105
  return !policy.safe || DERIVED_ERROR_FIELDS.has(key) || key === "_errorFieldsIncomplete" || policy.names.has(key);
@@ -993,26 +1196,30 @@ function toSanitizedError(value, seen, depth2, walk2) {
993
1196
  return { name: "SanitizeFailed", message: "Failed to sanitize the thrown value" };
994
1197
  }
995
1198
  }
996
- var ARGUMENT_FIELDS = /* @__PURE__ */ new Set(["args", "parameters"]);
997
- var DATABASE_VALUE_FIELDS = /* @__PURE__ */ new Set(["detail", "where", "internalQuery"]);
1199
+ var ARGUMENT_FIELDS = capturedSet(["args", "parameters"]);
1200
+ var DATABASE_VALUE_FIELDS = capturedSet(["detail", "where", "internalQuery"]);
998
1201
  var SQLSTATE = /^[0-9A-DF-Z][0-9A-Z]{4}$/;
999
1202
  var OMIT_OWN_FIELD = /* @__PURE__ */ Symbol("omit-own-field");
1203
+ function ownDataValue(source, key) {
1204
+ const descriptor = Object.getOwnPropertyDescriptor(source, key);
1205
+ return descriptor !== void 0 && Object.hasOwn(descriptor, "value") ? descriptor.value : void 0;
1206
+ }
1000
1207
  function isDatabaseError(source) {
1001
- const code = Object.getOwnPropertyDescriptor(source, "code")?.value;
1002
- return typeof code === "string" && SQLSTATE.test(code);
1208
+ const code = ownDataValue(source, "code");
1209
+ return typeof code === "string" && matchesPattern(SQLSTATE, code);
1003
1210
  }
1004
1211
  function ownFieldForLog(source, key, value, policy = ALL_OWN_FIELDS) {
1005
1212
  if (!allowsOwnField(policy, key)) return OMIT_OWN_FIELD;
1006
- if (ARGUMENT_FIELDS.has(key.toLowerCase())) return OMIT_OWN_FIELD;
1213
+ if (ARGUMENT_FIELDS.has(lowerCase(key))) return OMIT_OWN_FIELD;
1007
1214
  if (DATABASE_VALUE_FIELDS.has(key) && isDatabaseError(source)) return OMIT_OWN_FIELD;
1008
1215
  if (key !== "command" || typeof value !== "object" || value === null) {
1009
1216
  return withBinaryAsSize(value);
1010
1217
  }
1011
- const name = Object.getOwnPropertyDescriptor(value, "name")?.value;
1218
+ const name = ownDataValue(value, "name");
1012
1219
  return typeof name === "string" ? { name } : OMIT_OWN_FIELD;
1013
1220
  }
1014
1221
  function defineErrorField(target, key, value) {
1015
- Object.defineProperty(target, key, { value, enumerable: true });
1222
+ Object.defineProperty(target, key, bareDescriptor({ value, enumerable: true }));
1016
1223
  }
1017
1224
  function assignOwnErrorFields(target, source, policy = ALL_OWN_FIELDS) {
1018
1225
  try {
@@ -1029,7 +1236,11 @@ function assignOwnErrorFields(target, source, policy = ALL_OWN_FIELDS) {
1029
1236
  }
1030
1237
  }
1031
1238
  function markIncomplete(target) {
1032
- Reflect.defineProperty(target, "_errorFieldsIncomplete", { value: true, enumerable: true });
1239
+ Reflect.defineProperty(
1240
+ target,
1241
+ "_errorFieldsIncomplete",
1242
+ bareDescriptor({ value: true, enumerable: true })
1243
+ );
1033
1244
  }
1034
1245
  function readOptional(read, node) {
1035
1246
  try {
@@ -1064,7 +1275,7 @@ var MAX_PLAIN_NAME = 64;
1064
1275
  var PLAIN_NAME = /^[A-Za-z_$][\w$.-]*$/;
1065
1276
  function censorName(name, censorMessage) {
1066
1277
  if (censorMessage === void 0 || name === "") return name;
1067
- if (name.length <= MAX_PLAIN_NAME && PLAIN_NAME.test(name)) return name;
1278
+ if (name.length <= MAX_PLAIN_NAME && matchesPattern(PLAIN_NAME, name)) return name;
1068
1279
  try {
1069
1280
  return censorMessage(name);
1070
1281
  } catch {
@@ -1115,6 +1326,178 @@ function createWidthMarker(omitted) {
1115
1326
  return { _truncated: true, _reason: "aggregate-width-exceeded", _omitted: omitted };
1116
1327
  }
1117
1328
 
1329
+ // src/server/utils/redact-error-parts.util.ts
1330
+ function defineOwn(target, key, value) {
1331
+ Reflect.defineProperty(target, key, bareDescriptor({ value, enumerable: true, writable: true }));
1332
+ }
1333
+ var linkDepths = /* @__PURE__ */ new WeakMap();
1334
+ var ERROR_TEXT_FIELDS = capturedSet(["name", "message", "stack"]);
1335
+ var INCOMPLETE_KEY = "_errorFieldsIncomplete";
1336
+ var widthMarkers = /* @__PURE__ */ new WeakSet();
1337
+ function capErrors(errors, host) {
1338
+ if (!Array.isArray(errors) || errors.length <= MAX_AGGREGATE_ERRORS) return errors;
1339
+ if (host.hasToJson(errors)) return errors;
1340
+ const kept = [];
1341
+ for (let index = 0; index < MAX_AGGREGATE_ERRORS; index++) kept.push(Reflect.get(errors, index));
1342
+ const marker = createWidthMarker(errors.length - MAX_AGGREGATE_ERRORS);
1343
+ widthMarkers.add(marker);
1344
+ kept.push(marker);
1345
+ return kept;
1346
+ }
1347
+ function linkTargets(value) {
1348
+ const targets = [];
1349
+ const take = (link) => {
1350
+ if (typeof link === "object" && link !== null) targets.push(link);
1351
+ };
1352
+ if (!Array.isArray(value)) take(value);
1353
+ else for (let index = 0; index < value.length; index++) take(Reflect.get(value, index));
1354
+ return targets;
1355
+ }
1356
+ function walkChainPart(value, level, host, depth2) {
1357
+ const targets = linkTargets(value);
1358
+ if (targets.length > 0 && level + 1 > DEFAULT_MAX_CAUSE_DEPTH) {
1359
+ if (Array.isArray(value) && host.nameKey === "name") {
1360
+ return Array.from({ length: value.length }, (_member, index) => {
1361
+ const member = Reflect.get(value, index);
1362
+ return typeof member === "object" && member !== null && widthMarkers.has(member) ? member : createDepthMarker();
1363
+ });
1364
+ }
1365
+ return createDepthMarker();
1366
+ }
1367
+ const before = new Map(targets.map((target) => [target, linkDepths.get(target)]));
1368
+ for (const target of targets) linkDepths.set(target, level + 1);
1369
+ try {
1370
+ return host.walk(value, depth2 + 1);
1371
+ } finally {
1372
+ before.forEach((earlier, target) => {
1373
+ if (earlier === void 0) linkDepths.delete(target);
1374
+ else linkDepths.set(target, earlier);
1375
+ });
1376
+ }
1377
+ }
1378
+ function cutOrWalk(value, level, host, depth2) {
1379
+ return typeof value === "string" ? cutText(value) : walkChainPart(value, level, host, depth2);
1380
+ }
1381
+ function writeName(value, level, host, depth2) {
1382
+ const censored = host.censorName(typeof value === "string" ? cutText(value) : value);
1383
+ return censored === value ? cutOrWalk(value, level, host, depth2) : censored;
1384
+ }
1385
+ function addErrorParts(copy, error, ownKeys, host, depth2) {
1386
+ const taken = capturedSet(ownKeys);
1387
+ const level = linkDepths.get(error) ?? 0;
1388
+ let incomplete = false;
1389
+ const add = (key, covers, read, write = (value) => walkChainPart(value, level, host, depth2)) => {
1390
+ if (taken.has(key)) return;
1391
+ try {
1392
+ const written = write(read());
1393
+ if (written === void 0) return;
1394
+ const covered = covers.some((name) => host.sensitive.has(name));
1395
+ defineOwn(copy, key, covered ? host.censor : written);
1396
+ } catch {
1397
+ incomplete = true;
1398
+ }
1399
+ };
1400
+ add(
1401
+ host.nameKey,
1402
+ [host.nameKey, "name"],
1403
+ () => error.name,
1404
+ (name) => writeName(name, level, host, depth2)
1405
+ );
1406
+ add(
1407
+ "message",
1408
+ ["message"],
1409
+ () => error.message,
1410
+ (message) => cutOrWalk(message, level, host, depth2)
1411
+ );
1412
+ add(
1413
+ "stack",
1414
+ ["stack", "name", "message"],
1415
+ () => error.stack,
1416
+ (stack) => typeof stack === "string" ? scrubStack(stack) : void 0
1417
+ );
1418
+ add("cause", ["cause"], () => error.cause);
1419
+ add("errors", ["errors"], () => capErrors(error.errors, host));
1420
+ if (incomplete && !taken.has(INCOMPLETE_KEY)) defineOwn(copy, INCOMPLETE_KEY, true);
1421
+ }
1422
+
1423
+ // src/server/utils/error-text-exemption.util.ts
1424
+ var ERROR_TEXT_KEYS = capturedSet(["message"]);
1425
+ function leavesErrorText(rules, key, value, honorToJson) {
1426
+ return rules.errorTextToSerializer && !honorToJson && key === "err" && !Array.isArray(value);
1427
+ }
1428
+ function rulesBelow(rules, key, value, honorToJson) {
1429
+ if (leavesErrorText(rules, key, value, honorToJson)) {
1430
+ return { ...rules, exemptKeys: ERROR_TEXT_KEYS };
1431
+ }
1432
+ return rules.exemptKeys === void 0 && rules.headerKept !== true ? rules : { ...rules, exemptKeys: void 0, headerKept: void 0 };
1433
+ }
1434
+ function isCensored(rules, key, value) {
1435
+ return matchesKey(rules.sensitive, key) && !(typeof value === "string" && rules.exemptKeys?.has(key));
1436
+ }
1437
+ function messageCensor(rules) {
1438
+ return (text) => rules.sensitive.has("message") ? rules.censor : text;
1439
+ }
1440
+ var isStackKey = (key) => matchesKey(STACK_NAMES, key);
1441
+ var STACK_NAMES = capturedSet(["stack"]);
1442
+ var MESSAGE_NAMES = capturedSet(["message"]);
1443
+ var MAX_STACK_ALIASES = 8;
1444
+ var NO_STACK = { texts: /* @__PURE__ */ new Map(), stackKeys: capturedSet(), overflow: false };
1445
+ function headerMessage(rules, source, keys, isError2) {
1446
+ const keysOf = (names) => keys.filter((candidate) => matchesKey(names, candidate));
1447
+ const stacks = keysOf(STACK_NAMES);
1448
+ if (stacks.length === 0) return isError2 ? void 0 : NO_STACK;
1449
+ const hides = rules.sensitive.has("message") && (isError2 || rules.exemptKeys?.has("message") !== true && rules.headerKept !== true);
1450
+ const texts = /* @__PURE__ */ new Map();
1451
+ if (hides) {
1452
+ for (const key of keysOf(MESSAGE_NAMES)) {
1453
+ const text = Reflect.get(source, key);
1454
+ if (typeof text === "string") texts.set(key, text);
1455
+ }
1456
+ const named = keys.includes("message") ? void 0 : Reflect.get(source, "message");
1457
+ if (typeof named === "string") texts.set("message", named);
1458
+ }
1459
+ const overflow = stacks.length > MAX_STACK_ALIASES || capturedSet(texts.values()).size > MAX_STACK_ALIASES || [...texts.values()].some((text) => text.length > MAX_TEXT_LENGTH);
1460
+ return { texts, stackKeys: capturedSet(stacks), overflow };
1461
+ }
1462
+ function readField(source, key, header) {
1463
+ return header?.texts.get(key) ?? Reflect.get(source, key);
1464
+ }
1465
+ function censorAnyName(rules, name) {
1466
+ if (typeof name === "string") return censorName(name, messageCensor(rules));
1467
+ const holder = typeof name === "object" && name !== null || typeof name === "function";
1468
+ return holder && rules.sensitive.has("message") ? rules.censor : name;
1469
+ }
1470
+ function scrubPlainStack(rules, stack, header) {
1471
+ const texts = [...capturedSet(header?.texts.values())];
1472
+ const longest = texts.reduce((most, text) => Math.max(most, text.length), 0);
1473
+ const hidden = hideMessagesInStack(
1474
+ stack.slice(0, MAX_STACK_SCAN + longest),
1475
+ texts,
1476
+ rules.censor,
1477
+ MAX_STACK_SCAN
1478
+ );
1479
+ return scrubStack(hidden, void 0, stack.length > MAX_STACK_SCAN);
1480
+ }
1481
+ function errorTextField(rules, key, value, isError2, header) {
1482
+ const isStack = typeof value === "string" && (header === void 0 ? !isError2 && matchesKey(STACK_NAMES, key) : header.stackKeys.has(key));
1483
+ if (isStack) {
1484
+ return header?.overflow === true ? rules.censor : scrubPlainStack(rules, value, header);
1485
+ }
1486
+ if (!isError2 || !ERROR_TEXT_FIELDS.has(key)) return value;
1487
+ const cut = cutIfText(value);
1488
+ return key === "name" ? censorAnyName(rules, cut) : cut;
1489
+ }
1490
+
1491
+ // src/server/utils/is-plain-record.util.ts
1492
+ function isPlainRecord(node) {
1493
+ try {
1494
+ const prototype = Object.getPrototypeOf(node);
1495
+ return prototype === Object.prototype || prototype === null;
1496
+ } catch {
1497
+ return false;
1498
+ }
1499
+ }
1500
+
1118
1501
  // src/server/services/pino-logger.service.ts
1119
1502
  var OWNED_PAYLOAD_KEYS = ["logKey", "userId", "context"];
1120
1503
  var ENTRY_STRUCTURE_KEYS = ["level", "time", "msg", "service", "deployment"];
@@ -1125,17 +1508,17 @@ var RESOURCE_KEYS = [
1125
1508
  "service.instance.id",
1126
1509
  "deployment.environment.name"
1127
1510
  ];
1128
- var OWNED_KEY_SPELLINGS = new Set(
1511
+ var OWNED_KEY_SPELLINGS = capturedSet(
1129
1512
  [...OWNED_PAYLOAD_KEYS, ...ENTRY_STRUCTURE_KEYS, ...RESOURCE_KEYS].map((key) => foldKey(key))
1130
1513
  );
1131
- var DERIVED_KEYS = /* @__PURE__ */ new Set([
1514
+ var DERIVED_KEYS = capturedSet([
1132
1515
  "exception.type",
1133
1516
  "exception.message",
1134
1517
  "exception.stacktrace",
1135
1518
  "error.type"
1136
1519
  ]);
1137
1520
  var isOwnedKey = (key) => {
1138
- const lower = key.toLowerCase();
1521
+ const lower = lowerCase(key);
1139
1522
  return OWNED_KEY_SPELLINGS.has(foldKey(key)) || DERIVED_KEYS.has(foldKey(key, true)) || lower.startsWith("service.") || lower.startsWith("deployment.");
1140
1523
  };
1141
1524
  function withoutOwnedKeys(metadata, omit) {
@@ -1174,12 +1557,27 @@ function objectMessageText(fields) {
1174
1557
  }
1175
1558
  return void 0;
1176
1559
  }
1177
- function hideStackMessage(payload, text, censor) {
1178
- const stack = Reflect.get(payload, "stack");
1179
- if (text?.key !== "message" || typeof stack !== "string") return;
1560
+ function hideStackMessage(payload, text, censor, positional) {
1561
+ const kept = positional === void 0 ? void 0 : cutText(positional);
1562
+ if (text?.key !== "message") return kept;
1180
1563
  const censored = censor(text.text);
1181
- if (censored === text.text) return;
1182
- Reflect.set(payload, "stack", hideMessageInStack(stack, text.text, censored));
1564
+ if (censored === text.text) return kept;
1565
+ const keys = Object.keys(payload).filter(isStackKey);
1566
+ const overflow = keys.length + (positional === void 0 ? 0 : 1) > MAX_STACK_ALIASES || text.text.length > MAX_TEXT_LENGTH;
1567
+ const hide = (stack) => overflow ? censored : cutText(
1568
+ hideMessagesInStack(
1569
+ stack.slice(0, MAX_TEXT_LENGTH + text.text.length),
1570
+ [text.text],
1571
+ censored,
1572
+ MAX_TEXT_LENGTH
1573
+ ),
1574
+ stack.length > MAX_TEXT_LENGTH
1575
+ );
1576
+ for (const key of keys) {
1577
+ const stack = Reflect.get(payload, key);
1578
+ if (typeof stack === "string") Reflect.set(payload, key, hide(stack));
1579
+ }
1580
+ return positional === void 0 ? void 0 : hide(positional);
1183
1581
  }
1184
1582
  function readObjectMessage(message) {
1185
1583
  const fields = isPlainRecord(message) && !isErrorLike(message) ? message : void 0;
@@ -1200,9 +1598,12 @@ function findErrorParam(optionalParams) {
1200
1598
  }
1201
1599
  function assignIfDefined(payload, key, value) {
1202
1600
  if (value !== void 0) {
1203
- Reflect.defineProperty(payload, key, { value, enumerable: true });
1601
+ Reflect.defineProperty(payload, key, bareDescriptor({ value, enumerable: true }));
1204
1602
  }
1205
1603
  }
1604
+ function emitRecord(pino2, level, payload, msg) {
1605
+ if (pinoBuiltinsIntact()) pino2[level](payload, msg);
1606
+ }
1206
1607
  var PinoLoggerService = class {
1207
1608
  /**
1208
1609
  * **A hand-built instance is NOT this library's behaviour.** Constructing
@@ -1257,17 +1658,27 @@ var PinoLoggerService = class {
1257
1658
  if (isErrorLike(message)) {
1258
1659
  const payload2 = { err: message };
1259
1660
  assignIfDefined(payload2, "context", this.resolveContext(optionalParams));
1260
- this.pino.error(payload2, this.errorText(message));
1661
+ emitRecord(this.pino, "error", payload2, this.errorText(message));
1261
1662
  return;
1262
1663
  }
1263
1664
  const stack = typeof optionalParams[0] === "string" ? optionalParams[0] : void 0;
1264
1665
  const context = typeof optionalParams[1] === "string" ? optionalParams[1] : this.context;
1265
1666
  const { fields, text, payload } = readObjectMessage(message);
1266
- hideStackMessage(payload, text, (message2) => this.censorText({ key: "message", text: message2 }));
1667
+ const positional = hideStackMessage(
1668
+ payload,
1669
+ text,
1670
+ (message2) => this.censorText({ key: "message", text: message2 }),
1671
+ stack
1672
+ );
1267
1673
  assignIfDefined(payload, "context", context);
1268
- assignIfDefined(payload, "stack", stack === void 0 ? stack : cutText(stack));
1674
+ assignIfDefined(payload, "stack", positional);
1269
1675
  assignIfDefined(payload, "err", findErrorParam(optionalParams));
1270
- this.pino.error(payload, this.nestStyleMessage("error", void 0, fields, text, message));
1676
+ emitRecord(
1677
+ this.pino,
1678
+ "error",
1679
+ payload,
1680
+ this.nestStyleMessage("error", void 0, fields, text, message)
1681
+ );
1271
1682
  }
1272
1683
  /**
1273
1684
  * NestJS `warn` (warn level).
@@ -1353,7 +1764,7 @@ var PinoLoggerService = class {
1353
1764
  };
1354
1765
  assignIfDefined(payload, "userId", userId);
1355
1766
  assignIfDefined(payload, "context", this.context);
1356
- this.pino.error(payload, this.errorText(error));
1767
+ emitRecord(this.pino, "error", payload, this.errorText(error));
1357
1768
  }
1358
1769
  // ─── Helpers / escape hatches ─────────────────────────────────────────────
1359
1770
  /**
@@ -1413,9 +1824,9 @@ var PinoLoggerService = class {
1413
1824
  assignIfDefined(payload, "context", this.context);
1414
1825
  const line = toBoundedMessage(message);
1415
1826
  if (level === "info") {
1416
- this.pino.info(payload, line);
1827
+ emitRecord(this.pino, "info", payload, line);
1417
1828
  } else {
1418
- this.pino.warn(payload, line);
1829
+ emitRecord(this.pino, "warn", payload, line);
1419
1830
  }
1420
1831
  }
1421
1832
  /** Emit a NestJS-style variadic log, dispatching by level without computed indexing. */
@@ -1471,23 +1882,7 @@ var PinoLoggerService = class {
1471
1882
  const leading = isErrorLike(message) ? message : void 0;
1472
1883
  assignIfDefined(payload, "err", leading ?? findErrorParam(optionalParams));
1473
1884
  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
- }
1885
+ emitRecord(this.pino, level, payload, msg);
1491
1886
  }
1492
1887
  };
1493
1888
  PinoLoggerService = __decorateClass([
@@ -1681,6 +2076,7 @@ var NANOID_REGEX = /\/[A-Za-z0-9_-]{21}(?![A-Za-z0-9_-])/g;
1681
2076
  var NUMERIC_ID_REGEX = /\/\d+/g;
1682
2077
  var ID_PLACEHOLDER = "/:id";
1683
2078
  var SECRET_PLACEHOLDER = ":redacted";
2079
+ var WHOLE_PATH_PLACEHOLDER = `/${SECRET_PLACEHOLDER}`;
1684
2080
  var HEX_SECRET_REGEX = /^[0-9a-f]{32,}$/i;
1685
2081
  var JWT_SECRET_REGEX = /^eyJ[\w-]*\.[\w-]+\.[\w-]*$/;
1686
2082
  var TOKEN_SECRET_REGEX = /^[A-Za-z0-9_+/-]{32,}={0,2}$/;
@@ -1712,6 +2108,7 @@ function looksLikeToken(value) {
1712
2108
  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
2109
  }
1714
2110
  function secretPathSegments(url, extra = []) {
2111
+ if (!pinoBuiltinsIntact()) return [url];
1715
2112
  const found = /* @__PURE__ */ new Set();
1716
2113
  for (const segment of stripQueryString(url).split("/")) {
1717
2114
  if (isSecretSegment(segment, extra)) found.add(segment);
@@ -1719,6 +2116,7 @@ function secretPathSegments(url, extra = []) {
1719
2116
  return [...found];
1720
2117
  }
1721
2118
  function scrubSecretSegments(path2, extra = []) {
2119
+ if (!pinoBuiltinsIntact()) return WHOLE_PATH_PLACEHOLDER;
1722
2120
  return path2.split("/").map((segment) => isSecretSegment(segment, extra) ? SECRET_PLACEHOLDER : segment).join("/");
1723
2121
  }
1724
2122
  function normalizeUrl(url, extra = []) {
@@ -1729,6 +2127,7 @@ function stripQueryString(url) {
1729
2127
  return queryStart === -1 ? url : url.slice(0, queryStart);
1730
2128
  }
1731
2129
  function withoutRequestSecrets(text, extra, ...urls) {
2130
+ if (!pinoBuiltinsIntact()) return SECRET_PLACEHOLDER;
1732
2131
  let result = text;
1733
2132
  const segments = /* @__PURE__ */ new Set();
1734
2133
  for (const url of urls) {
@@ -2228,13 +2627,128 @@ var LogContextService = class {
2228
2627
  LogContextService = __decorateClass([
2229
2628
  Injectable()
2230
2629
  ], LogContextService);
2630
+ var IntrinsicPromise = Object.getPrototypeOf((async () => void 0)()).constructor;
2631
+ var hasOwn = Object.hasOwn;
2632
+ var isNativePromise = types.isPromise;
2633
+ var define = Object.defineProperty;
2634
+ var remove = Reflect.deleteProperty;
2635
+ var ownDescriptor = Reflect.getOwnPropertyDescriptor;
2636
+ var nativeThen = Function.prototype.call.bind(IntrinsicPromise.prototype.then);
2637
+ var promisePrototype = IntrinsicPromise.prototype;
2638
+ var speciesGetter = ownSpeciesGetter();
2639
+ var objectRoot = Object.prototype;
2640
+ var arrayRoot = Array.prototype;
2641
+ var functionRoot = Function.prototype;
2642
+ function ownSpeciesGetter() {
2643
+ const descriptor = ownDescriptor(IntrinsicPromise, Symbol.species);
2644
+ return descriptor !== void 0 && hasOwn(descriptor, "get") ? descriptor.get : void 0;
2645
+ }
2646
+ var PromiseTamperedError = class extends Error {
2647
+ constructor() {
2648
+ super(
2649
+ "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"
2650
+ );
2651
+ }
2652
+ };
2653
+ if (speciesGetter === void 0) throw new PromiseTamperedError();
2654
+ function promiseIntact() {
2655
+ const own = ownDescriptor(promisePrototype, "constructor");
2656
+ if (own === void 0 || !hasOwn(own, "value") || own.value !== IntrinsicPromise) return false;
2657
+ if (ownSpeciesGetter() !== speciesGetter) return false;
2658
+ return !hasOwn(objectRoot, "then") && !hasOwn(arrayRoot, "then") && !hasOwn(functionRoot, "then");
2659
+ }
2660
+ function intactOr(pending) {
2661
+ if (!promiseIntact()) throw new PromiseTamperedError();
2662
+ return pending;
2663
+ }
2664
+ function absorb(pending) {
2665
+ const drop = () => void 0;
2666
+ const pinned = pin(pending);
2667
+ try {
2668
+ try {
2669
+ nativeThen(pending, drop, drop);
2670
+ return;
2671
+ } catch {
2672
+ }
2673
+ void (async () => {
2674
+ try {
2675
+ await pending;
2676
+ } catch {
2677
+ }
2678
+ })();
2679
+ } finally {
2680
+ if (pinned) unpin(pending);
2681
+ }
2682
+ }
2683
+ function tag(promise) {
2684
+ setOwnConstructor(promise, false);
2685
+ return promise;
2686
+ }
2687
+ function setOwnConstructor(target, temporary) {
2688
+ try {
2689
+ define(target, "constructor", {
2690
+ __proto__: null,
2691
+ value: IntrinsicPromise,
2692
+ writable: temporary,
2693
+ configurable: temporary
2694
+ });
2695
+ return true;
2696
+ } catch {
2697
+ return false;
2698
+ }
2699
+ }
2700
+ function pin(target) {
2701
+ if (!isNativePromise(target) || hasOwn(target, "constructor")) return false;
2702
+ return setOwnConstructor(target, true);
2703
+ }
2704
+ function unpin(target) {
2705
+ try {
2706
+ remove(target, "constructor");
2707
+ } catch {
2708
+ }
2709
+ }
2710
+ function hold(value) {
2711
+ if (!isNativePromise(value)) return value;
2712
+ if (hasOwn(value, "constructor") || hasOwn(value, "then") || !setOwnConstructor(value, true)) {
2713
+ throw new PromiseTamperedError();
2714
+ }
2715
+ try {
2716
+ return (async () => {
2717
+ await value;
2718
+ })();
2719
+ } finally {
2720
+ unpin(value);
2721
+ }
2722
+ }
2723
+ function awaitOutcome(work, finish, held) {
2724
+ absorb(run(work, finish, held));
2725
+ }
2726
+ async function run(work, finish, held) {
2727
+ if (!promiseIntact()) {
2728
+ absorb(held);
2729
+ return finish({ __proto__: null, ok: false, cause: new PromiseTamperedError() });
2730
+ }
2731
+ let pending;
2732
+ try {
2733
+ pending = work();
2734
+ } catch (cause) {
2735
+ return finish({ __proto__: null, ok: false, cause });
2736
+ }
2737
+ try {
2738
+ await hold(intactOr(pending));
2739
+ } catch (cause) {
2740
+ if (cause instanceof PromiseTamperedError) absorb(pending);
2741
+ return finish({ __proto__: null, ok: false, cause });
2742
+ }
2743
+ finish({ __proto__: null, ok: true, cause: void 0 });
2744
+ }
2231
2745
 
2232
2746
  // src/server/middlewares/request-id.middleware.ts
2233
2747
  var REQUEST_ID_HEADER = "x-request-id";
2234
2748
  var MAX_CORRELATION_ID_LENGTH = 256;
2235
2749
  var CORRELATION_ID_CHARSET = /^[A-Za-z0-9._:/+=-]+$/;
2236
2750
  function settleLate(answer) {
2237
- Promise.resolve(answer).catch(() => void 0);
2751
+ absorb(answer);
2238
2752
  }
2239
2753
  var INHERITABLE_CONTEXT_KEYS = ["requestId", "tenantId"];
2240
2754
  function isAcceptableHeaderValue(value) {
@@ -2692,7 +3206,7 @@ function createTraceContextMixin(logContext, opts) {
2692
3206
  // src/server/utils/compile-redact-paths.util.ts
2693
3207
  function compileRedactPaths(extraPaths, shouldSkipDefaults) {
2694
3208
  const sources = shouldSkipDefaults ? [extraPaths] : [DEFAULT_REDACT_PATHS, extraPaths];
2695
- return Array.from(new Set(sources.flat()));
3209
+ return Array.from(capturedSet(sources.flat()));
2696
3210
  }
2697
3211
 
2698
3212
  // src/server/utils/cut-strings.util.ts
@@ -2840,15 +3354,14 @@ function destinationToStream(destination, health, maxQueueBytes = 0, censorMessa
2840
3354
  callback();
2841
3355
  } else {
2842
3356
  health.markWritePending(destination);
2843
- Promise.resolve(result).then(
2844
- () => {
3357
+ awaitOutcome(
3358
+ () => result,
3359
+ (outcome) => {
2845
3360
  health.markWriteSettled(destination);
2846
- callback();
3361
+ if (outcome.ok) callback();
3362
+ else onFailure(outcome.cause);
2847
3363
  },
2848
- (cause) => {
2849
- health.markWriteSettled(destination);
2850
- onFailure(cause);
2851
- }
3364
+ result
2852
3365
  );
2853
3366
  }
2854
3367
  } catch (cause) {
@@ -2867,11 +3380,11 @@ function mergeMixinSafely(mergeObject, mixinObject) {
2867
3380
  const merged = {};
2868
3381
  const written = /* @__PURE__ */ new Set();
2869
3382
  for (const [key, value] of Object.entries(mixinObject)) {
2870
- if (value !== void 0) written.add(foldKey(key));
3383
+ if (value !== void 0) setAdd(written, foldKey(key));
2871
3384
  }
2872
3385
  for (const key of Object.keys(mergeObject)) {
2873
3386
  if (key === PROTOTYPE_KEY) continue;
2874
- if (key !== EXPLICIT_USER_KEY && written.has(foldKey(key))) continue;
3387
+ if (key !== EXPLICIT_USER_KEY && setHas(written, foldKey(key))) continue;
2875
3388
  Reflect.set(merged, key, Reflect.get(mergeObject, key));
2876
3389
  }
2877
3390
  for (const [key, value] of Object.entries(mixinObject)) {
@@ -2897,225 +3410,79 @@ function censorRawHeaders(raw, sensitive, censor) {
2897
3410
  });
2898
3411
  }
2899
3412
 
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
3413
  // src/server/utils/redact-error-clone.util.ts
3064
3414
  function shadowHook(target) {
3065
- Reflect.defineProperty(target, "toJSON", { value: void 0, configurable: true });
3415
+ Reflect.defineProperty(target, "toJSON", bareDescriptor({ value: void 0, configurable: true }));
3066
3416
  }
3067
3417
  function withoutEnumerableKeys(clone) {
3068
3418
  for (const key of Object.keys(clone)) Reflect.deleteProperty(clone, key);
3069
3419
  }
3070
3420
  function discardWrite() {
3071
3421
  }
3072
- function cloneError(error) {
3073
- const descriptors = Object.getOwnPropertyDescriptors(error);
3074
- for (const descriptor of Object.values(descriptors)) {
3422
+ function relaxedDescriptors(descriptors) {
3423
+ const relaxed = /* @__PURE__ */ Object.create(null);
3424
+ for (const key of Reflect.ownKeys(descriptors)) {
3425
+ const descriptor = bareDescriptor(Reflect.get(descriptors, key));
3075
3426
  descriptor.configurable = true;
3076
- if ("value" in descriptor) descriptor.writable = true;
3427
+ if (Object.hasOwn(descriptor, "value")) descriptor.writable = true;
3077
3428
  else descriptor.set ??= discardWrite;
3429
+ Reflect.set(relaxed, key, descriptor);
3078
3430
  }
3079
- const clone = Object.create(Object.getPrototypeOf(error), descriptors);
3431
+ return relaxed;
3432
+ }
3433
+ function cloneError(error) {
3434
+ const clone = Object.create(
3435
+ Object.getPrototypeOf(error),
3436
+ relaxedDescriptors(Object.getOwnPropertyDescriptors(error))
3437
+ );
3080
3438
  const { stack } = error;
3081
3439
  if (typeof stack === "string") {
3082
- Reflect.defineProperty(clone, "stack", { value: stack, enumerable: false, writable: true });
3440
+ Reflect.defineProperty(
3441
+ clone,
3442
+ "stack",
3443
+ bareDescriptor({ value: stack, enumerable: false, writable: true })
3444
+ );
3083
3445
  }
3084
3446
  withoutEnumerableKeys(clone);
3085
3447
  shadowHook(clone);
3086
3448
  return clone;
3087
3449
  }
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]";
3450
+ var MAX_PROTOTYPE_HOPS2 = 256;
3099
3451
  function resolveToJson(value, viaGet = false) {
3100
3452
  let candidate = viaGet ? Reflect.get(value, "toJSON") : void 0;
3101
3453
  let accessor = false;
3102
3454
  let proxied = false;
3103
3455
  let current = viaGet ? null : value;
3104
- while (current !== null) {
3456
+ for (let hops = 0; current !== null; hops++) {
3457
+ if (hops > MAX_PROTOTYPE_HOPS2) return { method: void 0, volatile: true, hostile: true };
3105
3458
  proxied = proxied || types.isProxy(current);
3106
3459
  const descriptor = Object.getOwnPropertyDescriptor(current, "toJSON");
3107
3460
  if (descriptor !== void 0) {
3108
- accessor = descriptor.get !== void 0;
3109
- candidate = descriptor.get === void 0 ? descriptor.value : descriptor.get.call(value);
3461
+ const getter = Object.hasOwn(descriptor, "get") ? descriptor.get : void 0;
3462
+ accessor = getter !== void 0;
3463
+ if (getter !== void 0) candidate = getter.call(value);
3464
+ else if (Object.hasOwn(descriptor, "value")) candidate = descriptor.value;
3110
3465
  break;
3111
3466
  }
3112
- current = Object.getPrototypeOf(current);
3467
+ const next = Object.getPrototypeOf(current);
3468
+ current = typeof next === "object" ? next : null;
3113
3469
  }
3114
3470
  return {
3115
3471
  method: typeof candidate === "function" ? candidate : void 0,
3116
3472
  volatile: accessor || proxied
3117
3473
  };
3118
3474
  }
3475
+
3476
+ // src/server/utils/redact-by-name.util.ts
3477
+ var RAW_HEADER_KEYS = capturedSet(["rawheaders", "rawtrailers"]);
3478
+ function censorHeaderArray(key, walked, rules) {
3479
+ return matchesKey(RAW_HEADER_KEYS, key) && Array.isArray(walked) ? censorRawHeaders(walked, rules.headerNames, rules.censor) : walked;
3480
+ }
3481
+ var REDACT_MAX_TRAVERSAL_DEPTH = 100;
3482
+ var REDACT_DEPTH_EXCEEDED = "[REDACTION_DEPTH_EXCEEDED]";
3483
+ var REDACT_MAX_VISITS = 2e5;
3484
+ var REDACT_BUDGET_EXCEEDED = "[REDACTION_BUDGET_EXCEEDED]";
3485
+ var REDACT_CIRCULAR = "[Circular]";
3119
3486
  function rulesInside(rules, names, visits) {
3120
3487
  return names === void 0 ? void 0 : { ...rules, sensitive: names, visits, insideErrors: void 0 };
3121
3488
  }
@@ -3152,7 +3519,7 @@ function walk(value, rules, depth2, ancestors, honorToJson, inSerialized = false
3152
3519
  if (++rules.visits.count > rules.maxVisits) {
3153
3520
  return REDACT_BUDGET_EXCEEDED;
3154
3521
  }
3155
- if (ancestors.has(value)) {
3522
+ if (setHas(ancestors, value)) {
3156
3523
  return REDACT_CIRCULAR;
3157
3524
  }
3158
3525
  if (isError(value)) {
@@ -3180,7 +3547,8 @@ function walkObject(value, rules, depth2, ancestors, honorToJson, inSerialized)
3180
3547
  return withBinaryAsSize(value);
3181
3548
  }
3182
3549
  const resolved = resolveToJson(value, rules.ownFields.safe);
3183
- ancestors.add(value);
3550
+ if (resolved.hostile) return rules.censor;
3551
+ setAdd(ancestors, value);
3184
3552
  try {
3185
3553
  return walkForm(value, resolved, rules, depth2, ancestors, honorToJson, inSerialized);
3186
3554
  } finally {
@@ -3220,7 +3588,7 @@ function walkProperties(value, rules, depth2, ancestors, honorToJson, inSerializ
3220
3588
  const current = scrubbed ? ownFieldForLog(source, key, read, rules.ownFields) : read;
3221
3589
  const hook = honorToJson && key === "toJSON" && typeof current === "function";
3222
3590
  if (current === OMIT_OWN_FIELD || hook) {
3223
- omitted.add(key);
3591
+ setAdd(omitted, key);
3224
3592
  continue;
3225
3593
  }
3226
3594
  Reflect.deleteProperty(copy, key);
@@ -3248,7 +3616,7 @@ function walkProperties(value, rules, depth2, ancestors, honorToJson, inSerializ
3248
3616
  return copy;
3249
3617
  }
3250
3618
  function without(keys, omitted) {
3251
- return keys.filter((key) => !omitted.has(key));
3619
+ return keys.filter((key) => !setHas(omitted, key));
3252
3620
  }
3253
3621
  function startCopy(value, asData) {
3254
3622
  const clone = isError(value) ? cloneError(value) : void 0;
@@ -3273,7 +3641,7 @@ function createNameRedactor(fieldNames, censor, serializedKeys, maxVisits = REDA
3273
3641
  sensitive: foldedNames(fieldNames),
3274
3642
  headerNames: foldedNames(headerNames ?? fieldNames),
3275
3643
  censor,
3276
- serializedKeys: new Set(serializedKeys),
3644
+ serializedKeys: capturedSet(serializedKeys),
3277
3645
  errorsAsData: serializedKeys !== void 0,
3278
3646
  errorTextToSerializer,
3279
3647
  maxVisits,
@@ -3283,13 +3651,13 @@ function createNameRedactor(fieldNames, censor, serializedKeys, maxVisits = REDA
3283
3651
  return (value, isRecordRoot = false) => {
3284
3652
  try {
3285
3653
  const visits = { count: 0 };
3286
- const call = {
3654
+ const call2 = {
3287
3655
  ...rules,
3288
3656
  headerKept: typeof value === "object" && value !== null && errorOutputs.has(value),
3289
3657
  visits,
3290
3658
  insideErrors: rulesInside(rules, insideNames, visits)
3291
3659
  };
3292
- return walk(value, call, 0, /* @__PURE__ */ new Set(), !isRecordRoot);
3660
+ return walk(value, call2, 0, /* @__PURE__ */ new Set(), !isRecordRoot);
3293
3661
  } catch {
3294
3662
  return {
3295
3663
  _redactionFailed: true,
@@ -3326,7 +3694,11 @@ function parseResourceAttributes(raw) {
3326
3694
  } catch {
3327
3695
  value = rawValue;
3328
3696
  }
3329
- Object.defineProperty(parsed, key, { value, enumerable: true, configurable: true });
3697
+ Object.defineProperty(
3698
+ parsed,
3699
+ key,
3700
+ bareDescriptor({ value, enumerable: true, configurable: true })
3701
+ );
3330
3702
  }
3331
3703
  return parsed;
3332
3704
  }
@@ -3403,7 +3775,7 @@ function buildResourceBindings(resolved, format, extras = {}) {
3403
3775
  }
3404
3776
  return bindings;
3405
3777
  }
3406
- var OWNED_SERVICE_KEYS = /* @__PURE__ */ new Set([
3778
+ var OWNED_SERVICE_KEYS = capturedSet([
3407
3779
  "name",
3408
3780
  "version",
3409
3781
  "namespace",
@@ -3550,9 +3922,9 @@ var PATH_SEGMENT = /\[\s*['"]([^'"]+)['"]\s*\]|([^.[\]]+)/g;
3550
3922
  var INDEX_SEGMENT = /^\d+$/;
3551
3923
  function leafNameOf(path2) {
3552
3924
  let leaf;
3553
- for (const match of path2.matchAll(PATH_SEGMENT)) {
3925
+ for (const match of allMatches(PATH_SEGMENT, path2)) {
3554
3926
  const quoted = match[1];
3555
- const name = quoted ?? (match[2] !== void 0 && INDEX_SEGMENT.test(match[2]) ? void 0 : match[2]);
3927
+ const name = quoted ?? (match[2] !== void 0 && matchesPattern(INDEX_SEGMENT, match[2]) ? void 0 : match[2]);
3556
3928
  if (name !== void 0 && name !== "*") {
3557
3929
  leaf = name;
3558
3930
  }
@@ -3579,7 +3951,7 @@ function serializeErrorValue(value_, ownFields = ALL_OWN_FIELDS, censorMessage)
3579
3951
  return serialized;
3580
3952
  }
3581
3953
  function toEventName(logKey) {
3582
- return logKey.toLowerCase().replaceAll("_", ".");
3954
+ return replaceAllText(lowerCase(logKey), "_", ".");
3583
3955
  }
3584
3956
  function withEventName(record, field) {
3585
3957
  if (field === false) {
@@ -3604,7 +3976,7 @@ function resolveRecordRedactor(options) {
3604
3976
  );
3605
3977
  }
3606
3978
  function wholeRootKeys(options) {
3607
- return /* @__PURE__ */ new Set(["logKey", "err", ...Object.keys(options.serializers)]);
3979
+ return capturedSet(["logKey", "err", ...Object.keys(options.serializers)]);
3608
3980
  }
3609
3981
  function ownFieldPolicyOf(options) {
3610
3982
  return createOwnFieldPolicy(options.errorOwnFields, options.errorOwnFieldNames);
@@ -3643,7 +4015,7 @@ function buildNameRedactor(options, nestedErrorsAsData = false, coversNames = tr
3643
4015
  );
3644
4016
  }
3645
4017
  function resolveRedactOption(options) {
3646
- const paths = options.redactStrategy === "paths" ? compileRedactPaths(options.redactPaths, options.shouldDisableDefaultRedact) : [...new Set(options.redactPaths)];
4018
+ const paths = options.redactStrategy === "paths" ? compileRedactPaths(options.redactPaths, options.shouldDisableDefaultRedact) : [...capturedSet(options.redactPaths)];
3647
4019
  if (paths.length === 0) {
3648
4020
  return void 0;
3649
4021
  }
@@ -3686,6 +4058,10 @@ function buildTraceMixin(logContext, options) {
3686
4058
  censorMessage: buildMessageCensor(options)
3687
4059
  });
3688
4060
  }
4061
+ var UNSET_ENTRY_NAMES = {
4062
+ levelVal: void 0,
4063
+ write: void 0
4064
+ };
3689
4065
  function buildStreams(options, destinations, health) {
3690
4066
  const censorMessage = buildMessageCensor(options);
3691
4067
  return destinations.map((destination) => {
@@ -3697,6 +4073,7 @@ function buildStreams(options, destinations, health) {
3697
4073
  );
3698
4074
  health.registerStream(destination, stream);
3699
4075
  return {
4076
+ ...UNSET_ENTRY_NAMES,
3700
4077
  // Guarded: this runs at provider construction, BEFORE any lifecycle hook, so a
3701
4078
  // consumer implementing `minLevel` as a throwing getter would fail the factory
3702
4079
  // and the application would never start — earlier than any fail-soft path can
@@ -3753,10 +4130,24 @@ function buildFormatters(options, redactRecord, redactBindings, onTruncate) {
3753
4130
  log: buildRecordFormatter(options, redactRecord, onTruncate)
3754
4131
  };
3755
4132
  }
3756
- function buildPinoInstance(options, logContext, destinations, health) {
4133
+ var UNSET_PINO_NAMES = {
4134
+ transport: void 0,
4135
+ crlf: false,
4136
+ msgPrefix: void 0,
4137
+ name: void 0,
4138
+ writable: false,
4139
+ _writableState: void 0,
4140
+ prettyPrint: void 0,
4141
+ onChild: void 0
4142
+ };
4143
+ function refuseUnsafeOptions(options) {
4144
+ if (!pinoBuiltinsIntact()) throw new Error("LOGGER_BUILTINS_REPLACED");
3757
4145
  if (options.maxStringLength !== void 0) {
3758
4146
  refuseCensorBeyondLimit(options.redactCensor, options.maxStringLength);
3759
4147
  }
4148
+ }
4149
+ function buildPinoInstance(options, logContext, destinations, health) {
4150
+ refuseUnsafeOptions(options);
3760
4151
  const redactRecord = resolveRecordRedactor(options);
3761
4152
  const redactSerialized = buildNameRedactor(options);
3762
4153
  const ownFields = ownFieldPolicyOf(options);
@@ -3764,10 +4155,10 @@ function buildPinoInstance(options, logContext, destinations, health) {
3764
4155
  const onTruncate = (reason) => health.recordTruncation(reason);
3765
4156
  const pinoOptions = {
3766
4157
  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.
4158
+ ...redactOption === void 0 ? {} : { redact: { ...redactOption, remove: false } },
4159
+ ...UNSET_PINO_NAMES,
4160
+ // Resource identity, resolved ONCE here rather than per entry: Pino pre-serializes `base` into
4161
+ // the instance's chindings, so the extra attributes cost one string at construction.
3771
4162
  base: buildResourceBindings(
3772
4163
  resolveServiceMetadata(options.service),
3773
4164
  options.resourceFormat,
@@ -3806,7 +4197,7 @@ var DestinationHealth = class {
3806
4197
  this.entrySizeTruncations = 0;
3807
4198
  this.stringLengthTruncations = 0;
3808
4199
  /** Destinations whose `onInit()` rejected. Identity-keyed, not name-keyed. */
3809
- this.failed = /* @__PURE__ */ new Set();
4200
+ this.failed = capturedSet();
3810
4201
  /**
3811
4202
  * Destinations that initialized, each with its effective level as an index into
3812
4203
  * {@link LOG_LEVEL_PRIORITY}.
@@ -3832,7 +4223,7 @@ var DestinationHealth = class {
3832
4223
  * for the whole window — coarser than per-entry tracking, and wrong only in the
3833
4224
  * direction that duplicates rather than loses.
3834
4225
  */
3835
- this.writeFailed = /* @__PURE__ */ new Set();
4226
+ this.writeFailed = capturedSet();
3836
4227
  /**
3837
4228
  * In-flight asynchronous writes per destination.
3838
4229
  *
@@ -4088,20 +4479,21 @@ var HookTimeoutError = class extends Error {
4088
4479
  }
4089
4480
  };
4090
4481
  function withTimeout(work, ms) {
4091
- return new Promise((resolve, reject2) => {
4482
+ const wait = new IntrinsicPromise((resolve, reject2) => {
4092
4483
  const timer = setTimeout(() => {
4093
4484
  reject2(new HookTimeoutError(ms));
4094
4485
  }, 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
- }
4486
+ awaitOutcome(work, (outcome) => {
4487
+ if (outcome.ok) resolve();
4488
+ else reject2(outcome.cause);
4489
+ try {
4490
+ clearTimeout(timer);
4491
+ } catch {
4492
+ }
4493
+ });
4104
4494
  });
4495
+ absorb(wait);
4496
+ return tag(wait);
4105
4497
  }
4106
4498
 
4107
4499
  // src/server/services/destination-registry.service.ts
@@ -4151,7 +4543,9 @@ var DestinationRegistry = class {
4151
4543
  async onModuleInit() {
4152
4544
  for (const destination of this.registered) {
4153
4545
  try {
4154
- await withTimeout(() => destination.onInit?.(), this.options.destinationHookTimeoutMs);
4546
+ await intactOr(
4547
+ withTimeout(() => destination.onInit?.(), this.options.destinationHookTimeoutMs)
4548
+ );
4155
4549
  this.active.push(destination);
4156
4550
  this.health.markHealthy(destination, this.effectiveLevelOf(destination));
4157
4551
  } catch (cause) {
@@ -4183,14 +4577,16 @@ var DestinationRegistry = class {
4183
4577
  async notifyRegistryReady() {
4184
4578
  for (const destination of this.registered) {
4185
4579
  try {
4186
- await withTimeout(
4187
- () => destination.onRegistryReady?.({
4188
- heldEntriesDeliveredElsewhere: this.health.deliveredByHealthySink(
4189
- destination,
4190
- this.effectiveLevelOf(destination)
4191
- )
4192
- }),
4193
- this.options.destinationHookTimeoutMs
4580
+ await intactOr(
4581
+ withTimeout(
4582
+ () => destination.onRegistryReady?.({
4583
+ heldEntriesDeliveredElsewhere: this.health.deliveredByHealthySink(
4584
+ destination,
4585
+ this.effectiveLevelOf(destination)
4586
+ )
4587
+ }),
4588
+ this.options.destinationHookTimeoutMs
4589
+ )
4194
4590
  );
4195
4591
  } catch (cause) {
4196
4592
  this.reportHookFailure(destination, cause);
@@ -4332,7 +4728,7 @@ var DestinationRegistry = class {
4332
4728
  continue;
4333
4729
  }
4334
4730
  try {
4335
- await withTimeout(() => destination.onShutdown?.(), remaining);
4731
+ await intactOr(withTimeout(() => destination.onShutdown?.(), remaining));
4336
4732
  } catch (cause) {
4337
4733
  this.reportShutdownFailure(destination, cause);
4338
4734
  }
@@ -4711,7 +5107,7 @@ function productionRefusal() {
4711
5107
  );
4712
5108
  }
4713
5109
  async function buildTransform(view) {
4714
- const { build } = await import('pino-pretty');
5110
+ const { build } = await tag(import('pino-pretty'));
4715
5111
  return build({
4716
5112
  ...DEFAULT_VIEW,
4717
5113
  ...view,
@@ -4788,7 +5184,7 @@ var PrettyDevDestination = class {
4788
5184
  throw productionRefusal();
4789
5185
  }
4790
5186
  try {
4791
- this.stream = await buildTransform(this.view);
5187
+ this.stream = await tag(buildTransform(this.view));
4792
5188
  } catch (cause) {
4793
5189
  this.initFailed = true;
4794
5190
  throw initFailure(cause);