@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.
@@ -90,10 +90,36 @@ var GROUP_KEYS = {
90
90
  };
91
91
  var GROUP_NAMES = Object.keys(GROUP_KEYS);
92
92
  var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
93
+ var MAX_PROTOTYPE_HOPS = 256;
94
+ function rootHolding(source, key) {
95
+ let hops = 0;
96
+ for (let at = source; at !== null; at = Object.getPrototypeOf(at)) {
97
+ if (hops++ > MAX_PROTOTYPE_HOPS) {
98
+ refuse(
99
+ `[BymaxLoggerModule] options.${key} holds more than ${String(MAX_PROTOTYPE_HOPS)} prototypes`
100
+ );
101
+ }
102
+ if (Object.hasOwn(at, key)) {
103
+ return at !== source && Object.getPrototypeOf(at) === null ? at : void 0;
104
+ }
105
+ }
106
+ return void 0;
107
+ }
93
108
  function readSet(source, keys) {
94
- const set = {};
109
+ const set = /* @__PURE__ */ Object.create(null);
95
110
  for (const key of keys) {
111
+ const root = rootHolding(source, key);
112
+ const planted = root && Object.getOwnPropertyDescriptor(root, key);
113
+ const accessor = planted !== void 0 && Object.hasOwn(planted, "get") && planted.get !== void 0;
114
+ if (accessor) {
115
+ if (util.types.isProxy(source))
116
+ refuse(
117
+ `[BymaxLoggerModule] options.${key} is read through a Proxy while an accessor of that name is planted on Object.prototype`
118
+ );
119
+ continue;
120
+ }
96
121
  const value = Reflect.get(source, key);
122
+ if (planted && Object.hasOwn(planted, "value") && Object.is(value, planted.value)) continue;
97
123
  if (value !== void 0 && value !== null) Reflect.set(set, key, value);
98
124
  }
99
125
  return set;
@@ -130,7 +156,8 @@ function dropUnsetOptions(options) {
130
156
  Reflect.set(set, group, readSet(value, Object.keys(Reflect.get(GROUP_KEYS, group))));
131
157
  }
132
158
  const service = Reflect.get(set, "service");
133
- if (isRecord(service)) Reflect.set(set, "service", { ...service });
159
+ if (isRecord(service))
160
+ Reflect.set(set, "service", Object.assign(/* @__PURE__ */ Object.create(null), service));
134
161
  const serializers = Reflect.get(set, "serializers");
135
162
  if (isRecord(serializers)) Reflect.set(set, "serializers", { ...serializers });
136
163
  copyLists(set, LIST_OPTIONS, "");
@@ -195,7 +222,9 @@ function applyDefaults(given) {
195
222
  options.otel
196
223
  );
197
224
  const merged = {
198
- service: Object.freeze({ ...options.service }),
225
+ service: Object.freeze(
226
+ Object.assign(/* @__PURE__ */ Object.create(null), options.service)
227
+ ),
199
228
  level: options.level ?? (isProduction ? "info" : "debug"),
200
229
  isGlobal: options.isGlobal ?? true,
201
230
  shouldUseAsNestLogger: options.shouldUseAsNestLogger ?? true,
@@ -301,6 +330,7 @@ function checkGroup(path, value) {
301
330
  if (!isRecord2(value)) reject(path, "must be an object", value);
302
331
  return value;
303
332
  }
333
+ var MAX_REDACT_PATH_LENGTH = 256;
304
334
  var MAX_TIMER_MS = 2147483647;
305
335
  function checkTimerMs(path, value) {
306
336
  if (value === void 0) return;
@@ -415,6 +445,13 @@ function validateCustomization(options) {
415
445
  if (!isNonEmptyString(entry)) {
416
446
  reject(`redactPaths[${String(index)}]`, "must be a non-empty string", entry, true);
417
447
  }
448
+ if (entry.length > MAX_REDACT_PATH_LENGTH) {
449
+ reject(
450
+ `redactPaths[${String(index)}]`,
451
+ `must be at most ${String(MAX_REDACT_PATH_LENGTH)} characters`,
452
+ entry
453
+ );
454
+ }
418
455
  });
419
456
  }
420
457
  const serializers = options.serializers;
@@ -531,8 +568,131 @@ function validateOptions(given) {
531
568
  validateOtel(options);
532
569
  }
533
570
 
571
+ // src/server/utils/bare-descriptor.util.ts
572
+ var assign = Object.assign;
573
+ function bareDescriptor(descriptor) {
574
+ return assign(/* @__PURE__ */ Object.create(null), descriptor);
575
+ }
576
+
577
+ // src/server/utils/captured-builtins.util.ts
578
+ var call = Function.prototype.call;
579
+ var defineProperty = Object.defineProperty;
580
+ var setHas = call.bind(Set.prototype.has);
581
+ var setAdd = call.bind(Set.prototype.add);
582
+ var lowerCase = call.bind(String.prototype.toLowerCase);
583
+ var indexOfText = call.bind(String.prototype.indexOf);
584
+ var sliceText = call.bind(String.prototype.slice);
585
+ function replaceAllText(text, search, replacement) {
586
+ if (search === "") return text;
587
+ let result = "";
588
+ let from = 0;
589
+ for (let at = indexOfText(text, search, 0); at !== -1; at = indexOfText(text, search, from)) {
590
+ result += sliceText(text, from, at) + replacement;
591
+ from = at + search.length;
592
+ }
593
+ return result + sliceText(text, from);
594
+ }
595
+ var normalizeText = call.bind(String.prototype.normalize);
596
+ var regExpExec = call.bind(RegExp.prototype.exec);
597
+ var regExpReplace = call.bind(RegExp.prototype[Symbol.replace]);
598
+ function matchesPattern(pattern, text) {
599
+ return regExpExec(pattern, text) !== null;
600
+ }
601
+ function allMatches(pattern, text) {
602
+ const found = [];
603
+ pattern.lastIndex = 0;
604
+ for (let match = regExpExec(pattern, text); match !== null; match = regExpExec(pattern, text)) {
605
+ if (match[0] === "") break;
606
+ found[found.length] = match;
607
+ }
608
+ pattern.lastIndex = 0;
609
+ return found;
610
+ }
611
+ function replacer(pattern) {
612
+ defineProperty(
613
+ pattern,
614
+ "exec",
615
+ bareDescriptor({ value: (text) => regExpExec(pattern, text) })
616
+ );
617
+ return (text, replacement) => regExpReplace(pattern, text, replacement);
618
+ }
619
+ function capturedSet(values = []) {
620
+ const set = /* @__PURE__ */ new Set();
621
+ const has = (value) => setHas(set, value);
622
+ const add = (value) => {
623
+ setAdd(set, value);
624
+ return set;
625
+ };
626
+ defineProperty(set, "has", bareDescriptor({ value: has }));
627
+ defineProperty(set, "add", bareDescriptor({ value: add }));
628
+ if (Array.isArray(values)) for (let at = 0; at < values.length; at++) add(values[at]);
629
+ else for (const value of values) add(value);
630
+ return set;
631
+ }
632
+ function nextOf(iterator) {
633
+ return Object.getPrototypeOf(iterator);
634
+ }
635
+ var GUARDED_BUILTINS = [
636
+ [Array, ["from", "isArray"]],
637
+ [ArrayBuffer, ["isView"]],
638
+ [Buffer, ["byteLength", "from"]],
639
+ [Buffer.prototype, ["readUInt8", "subarray"]],
640
+ [
641
+ Array.prototype,
642
+ ["at", "filter", "flatMap", "forEach", "join", "map", "push", "reduce", "shift", "some", "sort"]
643
+ ],
644
+ [Array.prototype, [Symbol.iterator]],
645
+ [String, ["fromCodePoint"]],
646
+ [
647
+ String.prototype,
648
+ ["includes", "indexOf", "lastIndexOf", "normalize", "replace", "search", "slice", "split"]
649
+ ],
650
+ [String.prototype, ["charCodeAt", "startsWith", "toLowerCase", Symbol.iterator, Symbol.replace]],
651
+ [Map.prototype, ["clear", "get", "has", "set", Symbol.iterator]],
652
+ [Set.prototype, ["add", "delete", "has", "values", Symbol.iterator]],
653
+ [RegExp.prototype, ["exec", "test", Symbol.replace]],
654
+ [
655
+ Object,
656
+ ["assign", "create", "defineProperty", "entries", "fromEntries", "getOwnPropertyDescriptor"]
657
+ ],
658
+ [Function.prototype, ["call"]],
659
+ [Object, ["getOwnPropertyDescriptors", "getPrototypeOf", "hasOwn", "keys"]],
660
+ [
661
+ Reflect,
662
+ ["defineProperty", "deleteProperty", "get", "getOwnPropertyDescriptor", "ownKeys", "set"]
663
+ ],
664
+ [Math, ["max", "min"]],
665
+ [Number, ["isInteger"]],
666
+ [nextOf([][Symbol.iterator]()), ["next"]],
667
+ [nextOf(""[Symbol.iterator]()), ["next"]],
668
+ [nextOf((/* @__PURE__ */ new Map())[Symbol.iterator]()), ["next"]],
669
+ [nextOf((/* @__PURE__ */ new Set())[Symbol.iterator]()), ["next"]],
670
+ [nextOf(/(?:)/[Symbol.matchAll]("")), ["next"]]
671
+ ];
672
+ var guardedHolders = [];
673
+ var guardedMembers = [];
674
+ var guardedValues = [];
675
+ for (let at = 0; at < GUARDED_BUILTINS.length; at++) {
676
+ const entry = GUARDED_BUILTINS[at];
677
+ for (let member = 0; member < entry[1].length; member++) {
678
+ const name = entry[1][member];
679
+ guardedHolders[guardedHolders.length] = entry[0];
680
+ guardedMembers[guardedMembers.length] = name;
681
+ guardedValues[guardedValues.length] = entry[0][name];
682
+ }
683
+ }
684
+ function pinoBuiltinsIntact() {
685
+ for (let at = 0; at < guardedHolders.length; at++) {
686
+ if (guardedHolders[at][guardedMembers[at]] !== guardedValues[at]) {
687
+ return false;
688
+ }
689
+ }
690
+ return true;
691
+ }
692
+
534
693
  // src/server/config/resolve-options.ts
535
694
  function resolveOptions(given) {
695
+ if (!pinoBuiltinsIntact()) throw new Error("LOGGER_BUILTINS_REPLACED");
536
696
  return guardOptions(() => {
537
697
  const snapshot = dropUnsetOptions(given);
538
698
  validateOptions(snapshot);
@@ -586,7 +746,7 @@ var RESERVED_LOG_KEYS_NOT_EMITTED = Object.freeze({
586
746
  });
587
747
 
588
748
  // src/server/constants/prototype-polluting-keys.constants.ts
589
- var PROTOTYPE_POLLUTING_KEYS = /* @__PURE__ */ new Set([
749
+ var PROTOTYPE_POLLUTING_KEYS = capturedSet([
590
750
  "__proto__",
591
751
  "constructor",
592
752
  "prototype"
@@ -638,33 +798,35 @@ function createEntryTextFinisher(redact, limit, onCut) {
638
798
  };
639
799
  }
640
800
 
641
- // src/server/utils/escape-log-text.util.ts
642
- var LINE_TERMINATORS = /* @__PURE__ */ new Set(["\r", "\n", "\x85", "\u2028", "\u2029"]);
643
- var UNSAFE_IN_SINGLE_LINE = /[\u0000-\u0008\u000A-\u001F\u007F-\u009F\u2028\u2029\p{Cs}]/gu;
644
- var UNSAFE_IN_MULTILINE = /[\u0000-\u0008\u000B-\u001F\u007F-\u009F\u2028\u2029\p{Cs}]/gu;
645
- function toEscapeSequence(char) {
646
- return `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`;
647
- }
648
- function toSingleLineMessage(text) {
649
- return text.replace(
650
- UNSAFE_IN_SINGLE_LINE,
651
- (char) => LINE_TERMINATORS.has(char) ? "\\n" : toEscapeSequence(char)
652
- );
653
- }
654
- function toBoundedMessage(text) {
655
- return cutText(toSingleLineMessage(text));
656
- }
657
- function escapeControlCharacters(text) {
658
- return text.replace(UNSAFE_IN_MULTILINE, toEscapeSequence);
659
- }
801
+ // src/server/utils/glyph-letters.generated.ts
802
+ var GLYPH_LETTER_RUNS = [
803
+ [127312, "abcdefghijklmnopqrstuvwxyz"],
804
+ [127344, "abcdefghijklmnopqrstuvwxyzp"],
805
+ [127397, "d"],
806
+ [127462, "abcdefghijklmnopqrstuvwxyz"]
807
+ ];
660
808
 
661
809
  // src/server/utils/fold-key.util.ts
662
- var NOT_NAME = /[^\p{L}\p{N}]|[\u115f\u1160\u3164\uffa0]/gu;
663
- var INVISIBLE = /[\s\p{Cc}\p{Cf}\p{M}\u115f\u1160\u2800\u3164\uffa0]/gu;
664
- var DOTS = /[\u3002\u0701\u06d4\u22c5\u00b7\ufe12]/gu;
810
+ var dropNotName = replacer(/[^\p{L}\p{N}]|[\u115f\u1160\u3164\uffa0]/gu);
811
+ var SYMBOL_STAND_IN = "\uFFFC";
812
+ var standInSymbols = replacer(/(?=[^\0-\x7f])[\p{So}\p{Sm}\p{Sk}]/gu);
813
+ var dropNotNameStrict = replacer(/[^\p{L}\p{N}\ufffc]|[\u115f\u1160\u3164\uffa0]/gu);
814
+ var GLYPH_LETTERS = new Map(
815
+ GLYPH_LETTER_RUNS.flatMap(
816
+ ([first, letters]) => [...letters].map((letter, index) => [
817
+ String.fromCodePoint(first + index),
818
+ letter
819
+ ])
820
+ )
821
+ );
822
+ function readGlyphs(text) {
823
+ return Array.from(text, (glyph) => GLYPH_LETTERS.get(glyph) ?? glyph).join("");
824
+ }
825
+ var dropInvisible = replacer(/[\s\p{Cc}\p{Cf}\p{M}\u115f\u1160\u2800\u3164\uffa0]/gu);
826
+ var readDots = replacer(/[\u3002\u0701\u06d4\u22c5\u00b7\ufe12]/gu);
665
827
  var PLAIN = /^[\x21-\x7e]*$/;
666
828
  var NON_ASCII = /[^\x20-\x7e]/;
667
- var NOT_ASCII_NAME = /[^A-Za-z0-9]/g;
829
+ var dropNotAscii = replacer(/[^A-Za-z0-9]/g);
668
830
  var LOOKALIKES = new Map(
669
831
  Object.entries({
670
832
  a: "\u0430\u03B1\u1D00",
@@ -694,40 +856,60 @@ var LOOKALIKES = new Map(
694
856
  z: "\u1D22"
695
857
  }).flatMap(([latin, letters]) => [...letters].map((letter) => [letter, latin]))
696
858
  );
859
+ var LOOKALIKE_PAIRS = Array.from(LOOKALIKES);
697
860
  var I_LIKE = new Map(
698
861
  [..."\u0456\u03B9\u0131\u026A\u0269"].map((letter) => [letter, "i"])
699
862
  );
863
+ var I_LIKE_PAIRS = Array.from(I_LIKE);
700
864
  function foldKey(key, keepSeparators = false) {
701
865
  if (keepSeparators) {
702
- if (PLAIN.test(key)) return key.toLowerCase();
866
+ if (matchesPattern(PLAIN, key)) return lowerCase(key);
703
867
  return withLookalikes(
704
- key.normalize("NFKD").toLowerCase().replace(DOTS, ".").replace(INVISIBLE, ""),
868
+ dropInvisible(readDots(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), "."), ""),
705
869
  true
706
870
  );
707
871
  }
708
- if (PLAIN.test(key)) return key.replace(NOT_ASCII_NAME, "").toLowerCase();
709
- return withLookalikes(key.normalize("NFKD").toLowerCase().replace(NOT_NAME, ""), true);
872
+ if (matchesPattern(PLAIN, key)) return lowerCase(dropNotAscii(key, ""));
873
+ return withLookalikes(dropNotName(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), ""), true);
710
874
  }
711
875
  function foldStrict(key) {
712
- if (PLAIN.test(key)) return key.replace(NOT_ASCII_NAME, "").toLowerCase();
713
- return withLookalikes(key.normalize("NFKD").toLowerCase().replace(NOT_NAME, ""), false);
876
+ if (matchesPattern(PLAIN, key)) return lowerCase(dropNotAscii(key, ""));
877
+ return withLookalikes(
878
+ dropNotNameStrict(
879
+ standInSymbols(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), SYMBOL_STAND_IN),
880
+ ""
881
+ ),
882
+ false
883
+ );
714
884
  }
715
885
  function withLookalikes(folded, all) {
716
886
  let read = folded;
717
- for (const [letter, latin] of LOOKALIKES) read = read.replaceAll(letter, latin);
718
- if (all) for (const [letter, latin] of I_LIKE) read = read.replaceAll(letter, latin);
887
+ for (let at = 0; at < LOOKALIKE_PAIRS.length; at++) {
888
+ const [letter, latin] = LOOKALIKE_PAIRS[at];
889
+ read = replaceAllText(read, letter, latin);
890
+ }
891
+ if (all) {
892
+ for (let at = 0; at < I_LIKE_PAIRS.length; at++) {
893
+ const [letter, latin] = I_LIKE_PAIRS[at];
894
+ read = replaceAllText(read, letter, latin);
895
+ }
896
+ }
719
897
  return read;
720
898
  }
721
899
  var ALNUM = /^[A-Za-z0-9]*$/;
722
900
  function formOf(key) {
723
- return ALNUM.test(key) ? key.toLowerCase() : foldStrict(key);
901
+ return matchesPattern(ALNUM, key) ? lowerCase(key) : foldStrict(key);
724
902
  }
725
903
  var answers = /* @__PURE__ */ new WeakMap();
726
904
  function foldName(key) {
727
905
  return formOf(key);
728
906
  }
729
907
  function foldedNames(names) {
730
- return new Set(Array.from(names, foldName).filter((name) => name !== ""));
908
+ return capturedSet(
909
+ Array.from(names, (name) => replaceAllText(foldName(name), SYMBOL_STAND_IN, "")).filter(
910
+ (name) => name !== ""
911
+ )
912
+ );
731
913
  }
732
914
  var MAX_CANDIDATES = 64;
733
915
  var grouped = /* @__PURE__ */ new WeakMap();
@@ -750,34 +932,45 @@ function groupsOf(names) {
750
932
  }
751
933
  function matchesFolded(names, folded) {
752
934
  if (names.has(folded)) return true;
753
- if (!NON_ASCII.test(folded)) return false;
935
+ if (!matchesPattern(NON_ASCII, folded)) return false;
754
936
  const letters = [...folded];
755
937
  const wide = letters.filter((letter) => !isAscii(letter)).length;
938
+ const stands = letters.filter((letter) => letter === SYMBOL_STAND_IN).length;
756
939
  const { byLength, longest } = groupsOf(names);
757
- if (letters.length > longest) return false;
940
+ if (longest === 0) return false;
941
+ if (stands > longest) return true;
942
+ if (letters.length - stands > longest) return false;
758
943
  const lengths = Array.from(
759
- { length: wide + 1 },
760
- (_, extra) => byLength.get(letters.length + extra) ?? []
944
+ { length: wide + stands + 1 },
945
+ (_, extra) => byLength.get(letters.length - stands + extra) ?? []
761
946
  );
762
947
  if (lengths.reduce((count, same) => count + same.length, 0) > MAX_CANDIDATES) return true;
763
948
  return lengths.some((same) => same.some((name) => matchesName(letters, [...name])));
764
949
  }
765
950
  var isAscii = (letter) => letter < "\x80";
766
951
  function matchesName(letters, name) {
767
- let at = /* @__PURE__ */ new Set([0]);
952
+ const initial = /* @__PURE__ */ new Set();
953
+ setAdd(initial, 0);
954
+ let at = initial;
768
955
  for (const letter of letters) {
769
956
  const next = /* @__PURE__ */ new Set();
770
957
  for (const position of at) {
958
+ if (letter === SYMBOL_STAND_IN) {
959
+ setAdd(next, position);
960
+ setAdd(next, position + 1);
961
+ setAdd(next, position + 2);
962
+ continue;
963
+ }
771
964
  if (isAscii(letter)) {
772
- if (name[position] === letter) next.add(position + 1);
965
+ if (name[position] === letter) setAdd(next, position + 1);
773
966
  continue;
774
967
  }
775
- next.add(position + 1);
776
- next.add(position + 2);
968
+ setAdd(next, position + 1);
969
+ setAdd(next, position + 2);
777
970
  }
778
971
  at = next;
779
972
  }
780
- return at.has(name.length);
973
+ return setHas(at, name.length);
781
974
  }
782
975
  function matchesKey(names, key) {
783
976
  const seen = answers.get(names) ?? /* @__PURE__ */ new Map();
@@ -811,7 +1004,10 @@ function occurrences(stack, message) {
811
1004
  while (matched > 0 && stack[i] !== message[matched]) matched = table[matched - 1];
812
1005
  if (stack[i] === message[matched]) matched += 1;
813
1006
  if (matched === message.length) {
814
- spans.push([i + 1 - message.length, i + 1]);
1007
+ const start = i + 1 - message.length;
1008
+ const last = spans[spans.length - 1];
1009
+ if (last !== void 0 && start < last[1]) last[1] = i + 1;
1010
+ else spans.push([start, i + 1]);
815
1011
  }
816
1012
  }
817
1013
  return spans;
@@ -834,19 +1030,6 @@ function hideMessagesInStack(stack, messages, replacement, limit) {
834
1030
  }
835
1031
  return result + stack.slice(from, Math.max(end, from));
836
1032
  }
837
- function hideMessageInStack(stack, message, replacement) {
838
- return hideMessagesInStack(stack, [message], replacement, stack.length);
839
- }
840
-
841
- // src/server/utils/is-plain-record.util.ts
842
- function isPlainRecord(node) {
843
- try {
844
- const prototype = Object.getPrototypeOf(node);
845
- return prototype === Object.prototype || prototype === null;
846
- } catch {
847
- return false;
848
- }
849
- }
850
1033
 
851
1034
  // src/server/utils/censor-stack-header.util.ts
852
1035
  var NAME_SEPARATOR = ": ";
@@ -866,6 +1049,26 @@ function splitCensoredHeader(stack, name, message, censored) {
866
1049
  if (endsHeader(stack, message, 0)) return [censored, stack.slice(message.length)];
867
1050
  return [name === "" ? censored : name + NAME_SEPARATOR + censored, ""];
868
1051
  }
1052
+
1053
+ // src/server/utils/escape-log-text.util.ts
1054
+ var LINE_TERMINATORS = capturedSet(["\r", "\n", "\x85", "\u2028", "\u2029"]);
1055
+ var UNSAFE_IN_SINGLE_LINE = /[\u0000-\u0008\u000A-\u001F\u007F-\u009F\u2028\u2029\p{Cs}]/gu;
1056
+ var UNSAFE_IN_MULTILINE = /[\u0000-\u0008\u000B-\u001F\u007F-\u009F\u2028\u2029\p{Cs}]/gu;
1057
+ function toEscapeSequence(char) {
1058
+ return `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`;
1059
+ }
1060
+ function toSingleLineMessage(text) {
1061
+ return text.replace(
1062
+ UNSAFE_IN_SINGLE_LINE,
1063
+ (char) => LINE_TERMINATORS.has(char) ? "\\n" : toEscapeSequence(char)
1064
+ );
1065
+ }
1066
+ function toBoundedMessage(text) {
1067
+ return cutText(toSingleLineMessage(text));
1068
+ }
1069
+ function escapeControlCharacters(text) {
1070
+ return text.replace(UNSAFE_IN_MULTILINE, toEscapeSequence);
1071
+ }
869
1072
  function isError(value) {
870
1073
  try {
871
1074
  return util.types.isNativeError(value) || value instanceof Error;
@@ -889,17 +1092,17 @@ var DEFAULT_SAFE_ERROR_FIELDS = [
889
1092
  "schema",
890
1093
  "routine"
891
1094
  ];
892
- var DERIVED_ERROR_FIELDS = /* @__PURE__ */ new Set([
1095
+ var DERIVED_ERROR_FIELDS = capturedSet([
893
1096
  "name",
894
1097
  "message",
895
1098
  "stack",
896
1099
  "cause",
897
1100
  "errors"
898
1101
  ]);
899
- var ALL_OWN_FIELDS = { safe: false, names: /* @__PURE__ */ new Set() };
1102
+ var ALL_OWN_FIELDS = { safe: false, names: capturedSet() };
900
1103
  function createOwnFieldPolicy(mode, extraNames) {
901
1104
  if (mode === "all") return ALL_OWN_FIELDS;
902
- return { safe: true, names: /* @__PURE__ */ new Set([...DEFAULT_SAFE_ERROR_FIELDS, ...extraNames]) };
1105
+ return { safe: true, names: capturedSet([...DEFAULT_SAFE_ERROR_FIELDS, ...extraNames]) };
903
1106
  }
904
1107
  function allowsOwnField(policy, key) {
905
1108
  return !policy.safe || DERIVED_ERROR_FIELDS.has(key) || key === "_errorFieldsIncomplete" || policy.names.has(key);
@@ -996,26 +1199,30 @@ function toSanitizedError(value, seen, depth2, walk2) {
996
1199
  return { name: "SanitizeFailed", message: "Failed to sanitize the thrown value" };
997
1200
  }
998
1201
  }
999
- var ARGUMENT_FIELDS = /* @__PURE__ */ new Set(["args", "parameters"]);
1000
- var DATABASE_VALUE_FIELDS = /* @__PURE__ */ new Set(["detail", "where", "internalQuery"]);
1202
+ var ARGUMENT_FIELDS = capturedSet(["args", "parameters"]);
1203
+ var DATABASE_VALUE_FIELDS = capturedSet(["detail", "where", "internalQuery"]);
1001
1204
  var SQLSTATE = /^[0-9A-DF-Z][0-9A-Z]{4}$/;
1002
1205
  var OMIT_OWN_FIELD = /* @__PURE__ */ Symbol("omit-own-field");
1206
+ function ownDataValue(source, key) {
1207
+ const descriptor = Object.getOwnPropertyDescriptor(source, key);
1208
+ return descriptor !== void 0 && Object.hasOwn(descriptor, "value") ? descriptor.value : void 0;
1209
+ }
1003
1210
  function isDatabaseError(source) {
1004
- const code = Object.getOwnPropertyDescriptor(source, "code")?.value;
1005
- return typeof code === "string" && SQLSTATE.test(code);
1211
+ const code = ownDataValue(source, "code");
1212
+ return typeof code === "string" && matchesPattern(SQLSTATE, code);
1006
1213
  }
1007
1214
  function ownFieldForLog(source, key, value, policy = ALL_OWN_FIELDS) {
1008
1215
  if (!allowsOwnField(policy, key)) return OMIT_OWN_FIELD;
1009
- if (ARGUMENT_FIELDS.has(key.toLowerCase())) return OMIT_OWN_FIELD;
1216
+ if (ARGUMENT_FIELDS.has(lowerCase(key))) return OMIT_OWN_FIELD;
1010
1217
  if (DATABASE_VALUE_FIELDS.has(key) && isDatabaseError(source)) return OMIT_OWN_FIELD;
1011
1218
  if (key !== "command" || typeof value !== "object" || value === null) {
1012
1219
  return withBinaryAsSize(value);
1013
1220
  }
1014
- const name = Object.getOwnPropertyDescriptor(value, "name")?.value;
1221
+ const name = ownDataValue(value, "name");
1015
1222
  return typeof name === "string" ? { name } : OMIT_OWN_FIELD;
1016
1223
  }
1017
1224
  function defineErrorField(target, key, value) {
1018
- Object.defineProperty(target, key, { value, enumerable: true });
1225
+ Object.defineProperty(target, key, bareDescriptor({ value, enumerable: true }));
1019
1226
  }
1020
1227
  function assignOwnErrorFields(target, source, policy = ALL_OWN_FIELDS) {
1021
1228
  try {
@@ -1032,7 +1239,11 @@ function assignOwnErrorFields(target, source, policy = ALL_OWN_FIELDS) {
1032
1239
  }
1033
1240
  }
1034
1241
  function markIncomplete(target) {
1035
- Reflect.defineProperty(target, "_errorFieldsIncomplete", { value: true, enumerable: true });
1242
+ Reflect.defineProperty(
1243
+ target,
1244
+ "_errorFieldsIncomplete",
1245
+ bareDescriptor({ value: true, enumerable: true })
1246
+ );
1036
1247
  }
1037
1248
  function readOptional(read, node) {
1038
1249
  try {
@@ -1067,7 +1278,7 @@ var MAX_PLAIN_NAME = 64;
1067
1278
  var PLAIN_NAME = /^[A-Za-z_$][\w$.-]*$/;
1068
1279
  function censorName(name, censorMessage) {
1069
1280
  if (censorMessage === void 0 || name === "") return name;
1070
- if (name.length <= MAX_PLAIN_NAME && PLAIN_NAME.test(name)) return name;
1281
+ if (name.length <= MAX_PLAIN_NAME && matchesPattern(PLAIN_NAME, name)) return name;
1071
1282
  try {
1072
1283
  return censorMessage(name);
1073
1284
  } catch {
@@ -1118,6 +1329,178 @@ function createWidthMarker(omitted) {
1118
1329
  return { _truncated: true, _reason: "aggregate-width-exceeded", _omitted: omitted };
1119
1330
  }
1120
1331
 
1332
+ // src/server/utils/redact-error-parts.util.ts
1333
+ function defineOwn(target, key, value) {
1334
+ Reflect.defineProperty(target, key, bareDescriptor({ value, enumerable: true, writable: true }));
1335
+ }
1336
+ var linkDepths = /* @__PURE__ */ new WeakMap();
1337
+ var ERROR_TEXT_FIELDS = capturedSet(["name", "message", "stack"]);
1338
+ var INCOMPLETE_KEY = "_errorFieldsIncomplete";
1339
+ var widthMarkers = /* @__PURE__ */ new WeakSet();
1340
+ function capErrors(errors, host) {
1341
+ if (!Array.isArray(errors) || errors.length <= MAX_AGGREGATE_ERRORS) return errors;
1342
+ if (host.hasToJson(errors)) return errors;
1343
+ const kept = [];
1344
+ for (let index = 0; index < MAX_AGGREGATE_ERRORS; index++) kept.push(Reflect.get(errors, index));
1345
+ const marker = createWidthMarker(errors.length - MAX_AGGREGATE_ERRORS);
1346
+ widthMarkers.add(marker);
1347
+ kept.push(marker);
1348
+ return kept;
1349
+ }
1350
+ function linkTargets(value) {
1351
+ const targets = [];
1352
+ const take = (link) => {
1353
+ if (typeof link === "object" && link !== null) targets.push(link);
1354
+ };
1355
+ if (!Array.isArray(value)) take(value);
1356
+ else for (let index = 0; index < value.length; index++) take(Reflect.get(value, index));
1357
+ return targets;
1358
+ }
1359
+ function walkChainPart(value, level, host, depth2) {
1360
+ const targets = linkTargets(value);
1361
+ if (targets.length > 0 && level + 1 > DEFAULT_MAX_CAUSE_DEPTH) {
1362
+ if (Array.isArray(value) && host.nameKey === "name") {
1363
+ return Array.from({ length: value.length }, (_member, index) => {
1364
+ const member = Reflect.get(value, index);
1365
+ return typeof member === "object" && member !== null && widthMarkers.has(member) ? member : createDepthMarker();
1366
+ });
1367
+ }
1368
+ return createDepthMarker();
1369
+ }
1370
+ const before = new Map(targets.map((target) => [target, linkDepths.get(target)]));
1371
+ for (const target of targets) linkDepths.set(target, level + 1);
1372
+ try {
1373
+ return host.walk(value, depth2 + 1);
1374
+ } finally {
1375
+ before.forEach((earlier, target) => {
1376
+ if (earlier === void 0) linkDepths.delete(target);
1377
+ else linkDepths.set(target, earlier);
1378
+ });
1379
+ }
1380
+ }
1381
+ function cutOrWalk(value, level, host, depth2) {
1382
+ return typeof value === "string" ? cutText(value) : walkChainPart(value, level, host, depth2);
1383
+ }
1384
+ function writeName(value, level, host, depth2) {
1385
+ const censored = host.censorName(typeof value === "string" ? cutText(value) : value);
1386
+ return censored === value ? cutOrWalk(value, level, host, depth2) : censored;
1387
+ }
1388
+ function addErrorParts(copy, error, ownKeys, host, depth2) {
1389
+ const taken = capturedSet(ownKeys);
1390
+ const level = linkDepths.get(error) ?? 0;
1391
+ let incomplete = false;
1392
+ const add = (key, covers, read, write = (value) => walkChainPart(value, level, host, depth2)) => {
1393
+ if (taken.has(key)) return;
1394
+ try {
1395
+ const written = write(read());
1396
+ if (written === void 0) return;
1397
+ const covered = covers.some((name) => host.sensitive.has(name));
1398
+ defineOwn(copy, key, covered ? host.censor : written);
1399
+ } catch {
1400
+ incomplete = true;
1401
+ }
1402
+ };
1403
+ add(
1404
+ host.nameKey,
1405
+ [host.nameKey, "name"],
1406
+ () => error.name,
1407
+ (name) => writeName(name, level, host, depth2)
1408
+ );
1409
+ add(
1410
+ "message",
1411
+ ["message"],
1412
+ () => error.message,
1413
+ (message) => cutOrWalk(message, level, host, depth2)
1414
+ );
1415
+ add(
1416
+ "stack",
1417
+ ["stack", "name", "message"],
1418
+ () => error.stack,
1419
+ (stack) => typeof stack === "string" ? scrubStack(stack) : void 0
1420
+ );
1421
+ add("cause", ["cause"], () => error.cause);
1422
+ add("errors", ["errors"], () => capErrors(error.errors, host));
1423
+ if (incomplete && !taken.has(INCOMPLETE_KEY)) defineOwn(copy, INCOMPLETE_KEY, true);
1424
+ }
1425
+
1426
+ // src/server/utils/error-text-exemption.util.ts
1427
+ var ERROR_TEXT_KEYS = capturedSet(["message"]);
1428
+ function leavesErrorText(rules, key, value, honorToJson) {
1429
+ return rules.errorTextToSerializer && !honorToJson && key === "err" && !Array.isArray(value);
1430
+ }
1431
+ function rulesBelow(rules, key, value, honorToJson) {
1432
+ if (leavesErrorText(rules, key, value, honorToJson)) {
1433
+ return { ...rules, exemptKeys: ERROR_TEXT_KEYS };
1434
+ }
1435
+ return rules.exemptKeys === void 0 && rules.headerKept !== true ? rules : { ...rules, exemptKeys: void 0, headerKept: void 0 };
1436
+ }
1437
+ function isCensored(rules, key, value) {
1438
+ return matchesKey(rules.sensitive, key) && !(typeof value === "string" && rules.exemptKeys?.has(key));
1439
+ }
1440
+ function messageCensor(rules) {
1441
+ return (text) => rules.sensitive.has("message") ? rules.censor : text;
1442
+ }
1443
+ var isStackKey = (key) => matchesKey(STACK_NAMES, key);
1444
+ var STACK_NAMES = capturedSet(["stack"]);
1445
+ var MESSAGE_NAMES = capturedSet(["message"]);
1446
+ var MAX_STACK_ALIASES = 8;
1447
+ var NO_STACK = { texts: /* @__PURE__ */ new Map(), stackKeys: capturedSet(), overflow: false };
1448
+ function headerMessage(rules, source, keys, isError2) {
1449
+ const keysOf = (names) => keys.filter((candidate) => matchesKey(names, candidate));
1450
+ const stacks = keysOf(STACK_NAMES);
1451
+ if (stacks.length === 0) return isError2 ? void 0 : NO_STACK;
1452
+ const hides = rules.sensitive.has("message") && (isError2 || rules.exemptKeys?.has("message") !== true && rules.headerKept !== true);
1453
+ const texts = /* @__PURE__ */ new Map();
1454
+ if (hides) {
1455
+ for (const key of keysOf(MESSAGE_NAMES)) {
1456
+ const text = Reflect.get(source, key);
1457
+ if (typeof text === "string") texts.set(key, text);
1458
+ }
1459
+ const named = keys.includes("message") ? void 0 : Reflect.get(source, "message");
1460
+ if (typeof named === "string") texts.set("message", named);
1461
+ }
1462
+ const overflow = stacks.length > MAX_STACK_ALIASES || capturedSet(texts.values()).size > MAX_STACK_ALIASES || [...texts.values()].some((text) => text.length > MAX_TEXT_LENGTH);
1463
+ return { texts, stackKeys: capturedSet(stacks), overflow };
1464
+ }
1465
+ function readField(source, key, header) {
1466
+ return header?.texts.get(key) ?? Reflect.get(source, key);
1467
+ }
1468
+ function censorAnyName(rules, name) {
1469
+ if (typeof name === "string") return censorName(name, messageCensor(rules));
1470
+ const holder = typeof name === "object" && name !== null || typeof name === "function";
1471
+ return holder && rules.sensitive.has("message") ? rules.censor : name;
1472
+ }
1473
+ function scrubPlainStack(rules, stack, header) {
1474
+ const texts = [...capturedSet(header?.texts.values())];
1475
+ const longest = texts.reduce((most, text) => Math.max(most, text.length), 0);
1476
+ const hidden = hideMessagesInStack(
1477
+ stack.slice(0, MAX_STACK_SCAN + longest),
1478
+ texts,
1479
+ rules.censor,
1480
+ MAX_STACK_SCAN
1481
+ );
1482
+ return scrubStack(hidden, void 0, stack.length > MAX_STACK_SCAN);
1483
+ }
1484
+ function errorTextField(rules, key, value, isError2, header) {
1485
+ const isStack = typeof value === "string" && (header === void 0 ? !isError2 && matchesKey(STACK_NAMES, key) : header.stackKeys.has(key));
1486
+ if (isStack) {
1487
+ return header?.overflow === true ? rules.censor : scrubPlainStack(rules, value, header);
1488
+ }
1489
+ if (!isError2 || !ERROR_TEXT_FIELDS.has(key)) return value;
1490
+ const cut = cutIfText(value);
1491
+ return key === "name" ? censorAnyName(rules, cut) : cut;
1492
+ }
1493
+
1494
+ // src/server/utils/is-plain-record.util.ts
1495
+ function isPlainRecord(node) {
1496
+ try {
1497
+ const prototype = Object.getPrototypeOf(node);
1498
+ return prototype === Object.prototype || prototype === null;
1499
+ } catch {
1500
+ return false;
1501
+ }
1502
+ }
1503
+
1121
1504
  // src/server/services/pino-logger.service.ts
1122
1505
  var OWNED_PAYLOAD_KEYS = ["logKey", "userId", "context"];
1123
1506
  var ENTRY_STRUCTURE_KEYS = ["level", "time", "msg", "service", "deployment"];
@@ -1128,17 +1511,17 @@ var RESOURCE_KEYS = [
1128
1511
  "service.instance.id",
1129
1512
  "deployment.environment.name"
1130
1513
  ];
1131
- var OWNED_KEY_SPELLINGS = new Set(
1514
+ var OWNED_KEY_SPELLINGS = capturedSet(
1132
1515
  [...OWNED_PAYLOAD_KEYS, ...ENTRY_STRUCTURE_KEYS, ...RESOURCE_KEYS].map((key) => foldKey(key))
1133
1516
  );
1134
- var DERIVED_KEYS = /* @__PURE__ */ new Set([
1517
+ var DERIVED_KEYS = capturedSet([
1135
1518
  "exception.type",
1136
1519
  "exception.message",
1137
1520
  "exception.stacktrace",
1138
1521
  "error.type"
1139
1522
  ]);
1140
1523
  var isOwnedKey = (key) => {
1141
- const lower = key.toLowerCase();
1524
+ const lower = lowerCase(key);
1142
1525
  return OWNED_KEY_SPELLINGS.has(foldKey(key)) || DERIVED_KEYS.has(foldKey(key, true)) || lower.startsWith("service.") || lower.startsWith("deployment.");
1143
1526
  };
1144
1527
  function withoutOwnedKeys(metadata, omit) {
@@ -1177,12 +1560,27 @@ function objectMessageText(fields) {
1177
1560
  }
1178
1561
  return void 0;
1179
1562
  }
1180
- function hideStackMessage(payload, text, censor) {
1181
- const stack = Reflect.get(payload, "stack");
1182
- if (text?.key !== "message" || typeof stack !== "string") return;
1563
+ function hideStackMessage(payload, text, censor, positional) {
1564
+ const kept = positional === void 0 ? void 0 : cutText(positional);
1565
+ if (text?.key !== "message") return kept;
1183
1566
  const censored = censor(text.text);
1184
- if (censored === text.text) return;
1185
- Reflect.set(payload, "stack", hideMessageInStack(stack, text.text, censored));
1567
+ if (censored === text.text) return kept;
1568
+ const keys = Object.keys(payload).filter(isStackKey);
1569
+ const overflow = keys.length + (positional === void 0 ? 0 : 1) > MAX_STACK_ALIASES || text.text.length > MAX_TEXT_LENGTH;
1570
+ const hide = (stack) => overflow ? censored : cutText(
1571
+ hideMessagesInStack(
1572
+ stack.slice(0, MAX_TEXT_LENGTH + text.text.length),
1573
+ [text.text],
1574
+ censored,
1575
+ MAX_TEXT_LENGTH
1576
+ ),
1577
+ stack.length > MAX_TEXT_LENGTH
1578
+ );
1579
+ for (const key of keys) {
1580
+ const stack = Reflect.get(payload, key);
1581
+ if (typeof stack === "string") Reflect.set(payload, key, hide(stack));
1582
+ }
1583
+ return positional === void 0 ? void 0 : hide(positional);
1186
1584
  }
1187
1585
  function readObjectMessage(message) {
1188
1586
  const fields = isPlainRecord(message) && !isErrorLike(message) ? message : void 0;
@@ -1203,9 +1601,12 @@ function findErrorParam(optionalParams) {
1203
1601
  }
1204
1602
  function assignIfDefined(payload, key, value) {
1205
1603
  if (value !== void 0) {
1206
- Reflect.defineProperty(payload, key, { value, enumerable: true });
1604
+ Reflect.defineProperty(payload, key, bareDescriptor({ value, enumerable: true }));
1207
1605
  }
1208
1606
  }
1607
+ function emitRecord(pino2, level, payload, msg) {
1608
+ if (pinoBuiltinsIntact()) pino2[level](payload, msg);
1609
+ }
1209
1610
  exports.PinoLoggerService = class PinoLoggerService {
1210
1611
  /**
1211
1612
  * **A hand-built instance is NOT this library's behaviour.** Constructing
@@ -1260,17 +1661,27 @@ exports.PinoLoggerService = class PinoLoggerService {
1260
1661
  if (isErrorLike(message)) {
1261
1662
  const payload2 = { err: message };
1262
1663
  assignIfDefined(payload2, "context", this.resolveContext(optionalParams));
1263
- this.pino.error(payload2, this.errorText(message));
1664
+ emitRecord(this.pino, "error", payload2, this.errorText(message));
1264
1665
  return;
1265
1666
  }
1266
1667
  const stack = typeof optionalParams[0] === "string" ? optionalParams[0] : void 0;
1267
1668
  const context = typeof optionalParams[1] === "string" ? optionalParams[1] : this.context;
1268
1669
  const { fields, text, payload } = readObjectMessage(message);
1269
- hideStackMessage(payload, text, (message2) => this.censorText({ key: "message", text: message2 }));
1670
+ const positional = hideStackMessage(
1671
+ payload,
1672
+ text,
1673
+ (message2) => this.censorText({ key: "message", text: message2 }),
1674
+ stack
1675
+ );
1270
1676
  assignIfDefined(payload, "context", context);
1271
- assignIfDefined(payload, "stack", stack === void 0 ? stack : cutText(stack));
1677
+ assignIfDefined(payload, "stack", positional);
1272
1678
  assignIfDefined(payload, "err", findErrorParam(optionalParams));
1273
- this.pino.error(payload, this.nestStyleMessage("error", void 0, fields, text, message));
1679
+ emitRecord(
1680
+ this.pino,
1681
+ "error",
1682
+ payload,
1683
+ this.nestStyleMessage("error", void 0, fields, text, message)
1684
+ );
1274
1685
  }
1275
1686
  /**
1276
1687
  * NestJS `warn` (warn level).
@@ -1356,7 +1767,7 @@ exports.PinoLoggerService = class PinoLoggerService {
1356
1767
  };
1357
1768
  assignIfDefined(payload, "userId", userId);
1358
1769
  assignIfDefined(payload, "context", this.context);
1359
- this.pino.error(payload, this.errorText(error));
1770
+ emitRecord(this.pino, "error", payload, this.errorText(error));
1360
1771
  }
1361
1772
  // ─── Helpers / escape hatches ─────────────────────────────────────────────
1362
1773
  /**
@@ -1416,9 +1827,9 @@ exports.PinoLoggerService = class PinoLoggerService {
1416
1827
  assignIfDefined(payload, "context", this.context);
1417
1828
  const line = toBoundedMessage(message);
1418
1829
  if (level === "info") {
1419
- this.pino.info(payload, line);
1830
+ emitRecord(this.pino, "info", payload, line);
1420
1831
  } else {
1421
- this.pino.warn(payload, line);
1832
+ emitRecord(this.pino, "warn", payload, line);
1422
1833
  }
1423
1834
  }
1424
1835
  /** Emit a NestJS-style variadic log, dispatching by level without computed indexing. */
@@ -1474,23 +1885,7 @@ exports.PinoLoggerService = class PinoLoggerService {
1474
1885
  const leading = isErrorLike(message) ? message : void 0;
1475
1886
  assignIfDefined(payload, "err", leading ?? findErrorParam(optionalParams));
1476
1887
  const msg = this.nestStyleMessage(level, leading, fields, text, message);
1477
- switch (level) {
1478
- case "info":
1479
- this.pino.info(payload, msg);
1480
- break;
1481
- case "warn":
1482
- this.pino.warn(payload, msg);
1483
- break;
1484
- case "debug":
1485
- this.pino.debug(payload, msg);
1486
- break;
1487
- case "trace":
1488
- this.pino.trace(payload, msg);
1489
- break;
1490
- case "fatal":
1491
- this.pino.fatal(payload, msg);
1492
- break;
1493
- }
1888
+ emitRecord(this.pino, level, payload, msg);
1494
1889
  }
1495
1890
  };
1496
1891
  exports.PinoLoggerService = __decorateClass([
@@ -1684,6 +2079,7 @@ var NANOID_REGEX = /\/[A-Za-z0-9_-]{21}(?![A-Za-z0-9_-])/g;
1684
2079
  var NUMERIC_ID_REGEX = /\/\d+/g;
1685
2080
  var ID_PLACEHOLDER = "/:id";
1686
2081
  var SECRET_PLACEHOLDER = ":redacted";
2082
+ var WHOLE_PATH_PLACEHOLDER = `/${SECRET_PLACEHOLDER}`;
1687
2083
  var HEX_SECRET_REGEX = /^[0-9a-f]{32,}$/i;
1688
2084
  var JWT_SECRET_REGEX = /^eyJ[\w-]*\.[\w-]+\.[\w-]*$/;
1689
2085
  var TOKEN_SECRET_REGEX = /^[A-Za-z0-9_+/-]{32,}={0,2}$/;
@@ -1715,6 +2111,7 @@ function looksLikeToken(value) {
1715
2111
  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);
1716
2112
  }
1717
2113
  function secretPathSegments(url, extra = []) {
2114
+ if (!pinoBuiltinsIntact()) return [url];
1718
2115
  const found = /* @__PURE__ */ new Set();
1719
2116
  for (const segment of stripQueryString(url).split("/")) {
1720
2117
  if (isSecretSegment(segment, extra)) found.add(segment);
@@ -1722,6 +2119,7 @@ function secretPathSegments(url, extra = []) {
1722
2119
  return [...found];
1723
2120
  }
1724
2121
  function scrubSecretSegments(path, extra = []) {
2122
+ if (!pinoBuiltinsIntact()) return WHOLE_PATH_PLACEHOLDER;
1725
2123
  return path.split("/").map((segment) => isSecretSegment(segment, extra) ? SECRET_PLACEHOLDER : segment).join("/");
1726
2124
  }
1727
2125
  function normalizeUrl(url, extra = []) {
@@ -1732,6 +2130,7 @@ function stripQueryString(url) {
1732
2130
  return queryStart === -1 ? url : url.slice(0, queryStart);
1733
2131
  }
1734
2132
  function withoutRequestSecrets(text, extra, ...urls) {
2133
+ if (!pinoBuiltinsIntact()) return SECRET_PLACEHOLDER;
1735
2134
  let result = text;
1736
2135
  const segments = /* @__PURE__ */ new Set();
1737
2136
  for (const url of urls) {
@@ -2231,13 +2630,128 @@ exports.LogContextService = class LogContextService {
2231
2630
  exports.LogContextService = __decorateClass([
2232
2631
  common.Injectable()
2233
2632
  ], exports.LogContextService);
2633
+ var IntrinsicPromise = Object.getPrototypeOf((async () => void 0)()).constructor;
2634
+ var hasOwn = Object.hasOwn;
2635
+ var isNativePromise = util.types.isPromise;
2636
+ var define = Object.defineProperty;
2637
+ var remove = Reflect.deleteProperty;
2638
+ var ownDescriptor = Reflect.getOwnPropertyDescriptor;
2639
+ var nativeThen = Function.prototype.call.bind(IntrinsicPromise.prototype.then);
2640
+ var promisePrototype = IntrinsicPromise.prototype;
2641
+ var speciesGetter = ownSpeciesGetter();
2642
+ var objectRoot = Object.prototype;
2643
+ var arrayRoot = Array.prototype;
2644
+ var functionRoot = Function.prototype;
2645
+ function ownSpeciesGetter() {
2646
+ const descriptor = ownDescriptor(IntrinsicPromise, Symbol.species);
2647
+ return descriptor !== void 0 && hasOwn(descriptor, "get") ? descriptor.get : void 0;
2648
+ }
2649
+ var PromiseTamperedError = class extends Error {
2650
+ constructor() {
2651
+ super(
2652
+ "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"
2653
+ );
2654
+ }
2655
+ };
2656
+ if (speciesGetter === void 0) throw new PromiseTamperedError();
2657
+ function promiseIntact() {
2658
+ const own = ownDescriptor(promisePrototype, "constructor");
2659
+ if (own === void 0 || !hasOwn(own, "value") || own.value !== IntrinsicPromise) return false;
2660
+ if (ownSpeciesGetter() !== speciesGetter) return false;
2661
+ return !hasOwn(objectRoot, "then") && !hasOwn(arrayRoot, "then") && !hasOwn(functionRoot, "then");
2662
+ }
2663
+ function intactOr(pending) {
2664
+ if (!promiseIntact()) throw new PromiseTamperedError();
2665
+ return pending;
2666
+ }
2667
+ function absorb(pending) {
2668
+ const drop = () => void 0;
2669
+ const pinned = pin(pending);
2670
+ try {
2671
+ try {
2672
+ nativeThen(pending, drop, drop);
2673
+ return;
2674
+ } catch {
2675
+ }
2676
+ void (async () => {
2677
+ try {
2678
+ await pending;
2679
+ } catch {
2680
+ }
2681
+ })();
2682
+ } finally {
2683
+ if (pinned) unpin(pending);
2684
+ }
2685
+ }
2686
+ function tag(promise) {
2687
+ setOwnConstructor(promise, false);
2688
+ return promise;
2689
+ }
2690
+ function setOwnConstructor(target, temporary) {
2691
+ try {
2692
+ define(target, "constructor", {
2693
+ __proto__: null,
2694
+ value: IntrinsicPromise,
2695
+ writable: temporary,
2696
+ configurable: temporary
2697
+ });
2698
+ return true;
2699
+ } catch {
2700
+ return false;
2701
+ }
2702
+ }
2703
+ function pin(target) {
2704
+ if (!isNativePromise(target) || hasOwn(target, "constructor")) return false;
2705
+ return setOwnConstructor(target, true);
2706
+ }
2707
+ function unpin(target) {
2708
+ try {
2709
+ remove(target, "constructor");
2710
+ } catch {
2711
+ }
2712
+ }
2713
+ function hold(value) {
2714
+ if (!isNativePromise(value)) return value;
2715
+ if (hasOwn(value, "constructor") || hasOwn(value, "then") || !setOwnConstructor(value, true)) {
2716
+ throw new PromiseTamperedError();
2717
+ }
2718
+ try {
2719
+ return (async () => {
2720
+ await value;
2721
+ })();
2722
+ } finally {
2723
+ unpin(value);
2724
+ }
2725
+ }
2726
+ function awaitOutcome(work, finish, held) {
2727
+ absorb(run(work, finish, held));
2728
+ }
2729
+ async function run(work, finish, held) {
2730
+ if (!promiseIntact()) {
2731
+ absorb(held);
2732
+ return finish({ __proto__: null, ok: false, cause: new PromiseTamperedError() });
2733
+ }
2734
+ let pending;
2735
+ try {
2736
+ pending = work();
2737
+ } catch (cause) {
2738
+ return finish({ __proto__: null, ok: false, cause });
2739
+ }
2740
+ try {
2741
+ await hold(intactOr(pending));
2742
+ } catch (cause) {
2743
+ if (cause instanceof PromiseTamperedError) absorb(pending);
2744
+ return finish({ __proto__: null, ok: false, cause });
2745
+ }
2746
+ finish({ __proto__: null, ok: true, cause: void 0 });
2747
+ }
2234
2748
 
2235
2749
  // src/server/middlewares/request-id.middleware.ts
2236
2750
  var REQUEST_ID_HEADER = "x-request-id";
2237
2751
  var MAX_CORRELATION_ID_LENGTH = 256;
2238
2752
  var CORRELATION_ID_CHARSET = /^[A-Za-z0-9._:/+=-]+$/;
2239
2753
  function settleLate(answer) {
2240
- Promise.resolve(answer).catch(() => void 0);
2754
+ absorb(answer);
2241
2755
  }
2242
2756
  var INHERITABLE_CONTEXT_KEYS = ["requestId", "tenantId"];
2243
2757
  function isAcceptableHeaderValue(value) {
@@ -2695,7 +3209,7 @@ function createTraceContextMixin(logContext, opts) {
2695
3209
  // src/server/utils/compile-redact-paths.util.ts
2696
3210
  function compileRedactPaths(extraPaths, shouldSkipDefaults) {
2697
3211
  const sources = shouldSkipDefaults ? [extraPaths] : [DEFAULT_REDACT_PATHS, extraPaths];
2698
- return Array.from(new Set(sources.flat()));
3212
+ return Array.from(capturedSet(sources.flat()));
2699
3213
  }
2700
3214
 
2701
3215
  // src/server/utils/cut-strings.util.ts
@@ -2843,15 +3357,14 @@ function destinationToStream(destination, health, maxQueueBytes = 0, censorMessa
2843
3357
  callback();
2844
3358
  } else {
2845
3359
  health.markWritePending(destination);
2846
- Promise.resolve(result).then(
2847
- () => {
3360
+ awaitOutcome(
3361
+ () => result,
3362
+ (outcome) => {
2848
3363
  health.markWriteSettled(destination);
2849
- callback();
3364
+ if (outcome.ok) callback();
3365
+ else onFailure(outcome.cause);
2850
3366
  },
2851
- (cause) => {
2852
- health.markWriteSettled(destination);
2853
- onFailure(cause);
2854
- }
3367
+ result
2855
3368
  );
2856
3369
  }
2857
3370
  } catch (cause) {
@@ -2870,11 +3383,11 @@ function mergeMixinSafely(mergeObject, mixinObject) {
2870
3383
  const merged = {};
2871
3384
  const written = /* @__PURE__ */ new Set();
2872
3385
  for (const [key, value] of Object.entries(mixinObject)) {
2873
- if (value !== void 0) written.add(foldKey(key));
3386
+ if (value !== void 0) setAdd(written, foldKey(key));
2874
3387
  }
2875
3388
  for (const key of Object.keys(mergeObject)) {
2876
3389
  if (key === PROTOTYPE_KEY) continue;
2877
- if (key !== EXPLICIT_USER_KEY && written.has(foldKey(key))) continue;
3390
+ if (key !== EXPLICIT_USER_KEY && setHas(written, foldKey(key))) continue;
2878
3391
  Reflect.set(merged, key, Reflect.get(mergeObject, key));
2879
3392
  }
2880
3393
  for (const [key, value] of Object.entries(mixinObject)) {
@@ -2900,225 +3413,79 @@ function censorRawHeaders(raw, sensitive, censor) {
2900
3413
  });
2901
3414
  }
2902
3415
 
2903
- // src/server/utils/redact-error-parts.util.ts
2904
- function defineOwn(target, key, value) {
2905
- Reflect.defineProperty(target, key, { value, enumerable: true, writable: true });
2906
- }
2907
- var linkDepths = /* @__PURE__ */ new WeakMap();
2908
- var ERROR_TEXT_FIELDS = /* @__PURE__ */ new Set(["name", "message", "stack"]);
2909
- var INCOMPLETE_KEY = "_errorFieldsIncomplete";
2910
- var widthMarkers = /* @__PURE__ */ new WeakSet();
2911
- function capErrors(errors, host) {
2912
- if (!Array.isArray(errors) || errors.length <= MAX_AGGREGATE_ERRORS) return errors;
2913
- if (host.hasToJson(errors)) return errors;
2914
- const kept = [];
2915
- for (let index = 0; index < MAX_AGGREGATE_ERRORS; index++) kept.push(Reflect.get(errors, index));
2916
- const marker = createWidthMarker(errors.length - MAX_AGGREGATE_ERRORS);
2917
- widthMarkers.add(marker);
2918
- kept.push(marker);
2919
- return kept;
2920
- }
2921
- function linkTargets(value) {
2922
- const targets = [];
2923
- const take = (link) => {
2924
- if (typeof link === "object" && link !== null) targets.push(link);
2925
- };
2926
- if (!Array.isArray(value)) take(value);
2927
- else for (let index = 0; index < value.length; index++) take(Reflect.get(value, index));
2928
- return targets;
2929
- }
2930
- function walkChainPart(value, level, host, depth2) {
2931
- const targets = linkTargets(value);
2932
- if (targets.length > 0 && level + 1 > DEFAULT_MAX_CAUSE_DEPTH) {
2933
- if (Array.isArray(value) && host.nameKey === "name") {
2934
- return Array.from({ length: value.length }, (_member, index) => {
2935
- const member = Reflect.get(value, index);
2936
- return typeof member === "object" && member !== null && widthMarkers.has(member) ? member : createDepthMarker();
2937
- });
2938
- }
2939
- return createDepthMarker();
2940
- }
2941
- const before = new Map(targets.map((target) => [target, linkDepths.get(target)]));
2942
- for (const target of targets) linkDepths.set(target, level + 1);
2943
- try {
2944
- return host.walk(value, depth2 + 1);
2945
- } finally {
2946
- before.forEach((earlier, target) => {
2947
- if (earlier === void 0) linkDepths.delete(target);
2948
- else linkDepths.set(target, earlier);
2949
- });
2950
- }
2951
- }
2952
- function cutOrWalk(value, level, host, depth2) {
2953
- return typeof value === "string" ? cutText(value) : walkChainPart(value, level, host, depth2);
2954
- }
2955
- function writeName(value, level, host, depth2) {
2956
- const censored = host.censorName(typeof value === "string" ? cutText(value) : value);
2957
- return censored === value ? cutOrWalk(value, level, host, depth2) : censored;
2958
- }
2959
- function addErrorParts(copy, error, ownKeys, host, depth2) {
2960
- const taken = new Set(ownKeys);
2961
- const level = linkDepths.get(error) ?? 0;
2962
- let incomplete = false;
2963
- const add = (key, covers, read, write = (value) => walkChainPart(value, level, host, depth2)) => {
2964
- if (taken.has(key)) return;
2965
- try {
2966
- const written = write(read());
2967
- if (written === void 0) return;
2968
- const covered = covers.some((name) => host.sensitive.has(name));
2969
- defineOwn(copy, key, covered ? host.censor : written);
2970
- } catch {
2971
- incomplete = true;
2972
- }
2973
- };
2974
- add(
2975
- host.nameKey,
2976
- [host.nameKey, "name"],
2977
- () => error.name,
2978
- (name) => writeName(name, level, host, depth2)
2979
- );
2980
- add(
2981
- "message",
2982
- ["message"],
2983
- () => error.message,
2984
- (message) => cutOrWalk(message, level, host, depth2)
2985
- );
2986
- add(
2987
- "stack",
2988
- ["stack", "name", "message"],
2989
- () => error.stack,
2990
- (stack) => typeof stack === "string" ? scrubStack(stack) : void 0
2991
- );
2992
- add("cause", ["cause"], () => error.cause);
2993
- add("errors", ["errors"], () => capErrors(error.errors, host));
2994
- if (incomplete && !taken.has(INCOMPLETE_KEY)) defineOwn(copy, INCOMPLETE_KEY, true);
2995
- }
2996
-
2997
- // src/server/utils/error-text-exemption.util.ts
2998
- var ERROR_TEXT_KEYS = /* @__PURE__ */ new Set(["message"]);
2999
- function leavesErrorText(rules, key, value, honorToJson) {
3000
- return rules.errorTextToSerializer && !honorToJson && key === "err" && !Array.isArray(value);
3001
- }
3002
- function rulesBelow(rules, key, value, honorToJson) {
3003
- if (leavesErrorText(rules, key, value, honorToJson)) {
3004
- return { ...rules, exemptKeys: ERROR_TEXT_KEYS };
3005
- }
3006
- return rules.exemptKeys === void 0 && rules.headerKept !== true ? rules : { ...rules, exemptKeys: void 0, headerKept: void 0 };
3007
- }
3008
- function isCensored(rules, key, value) {
3009
- return matchesKey(rules.sensitive, key) && !(typeof value === "string" && rules.exemptKeys?.has(key));
3010
- }
3011
- function messageCensor(rules) {
3012
- return (text) => rules.sensitive.has("message") ? rules.censor : text;
3013
- }
3014
- var STACK_NAMES = /* @__PURE__ */ new Set(["stack"]);
3015
- var MESSAGE_NAMES = /* @__PURE__ */ new Set(["message"]);
3016
- var MAX_STACK_ALIASES = 8;
3017
- var NO_STACK = { texts: /* @__PURE__ */ new Map(), stackKeys: /* @__PURE__ */ new Set(), overflow: false };
3018
- function headerMessage(rules, source, keys, isError2) {
3019
- if (isError2) return void 0;
3020
- const keysOf = (names) => keys.filter((candidate) => matchesKey(names, candidate));
3021
- const stacks = keysOf(STACK_NAMES);
3022
- if (stacks.length === 0) return NO_STACK;
3023
- const hides = rules.sensitive.has("message") && rules.exemptKeys?.has("message") !== true && rules.headerKept !== true;
3024
- const texts = /* @__PURE__ */ new Map();
3025
- if (hides) {
3026
- for (const key of keysOf(MESSAGE_NAMES)) {
3027
- const text = Reflect.get(source, key);
3028
- if (typeof text === "string") texts.set(key, text);
3029
- }
3030
- const named = keys.includes("message") ? void 0 : Reflect.get(source, "message");
3031
- if (typeof named === "string") texts.set("message", named);
3032
- }
3033
- const overflow = stacks.length > MAX_STACK_ALIASES || new Set(texts.values()).size > MAX_STACK_ALIASES;
3034
- return { texts, stackKeys: new Set(stacks), overflow };
3035
- }
3036
- function readField(source, key, header) {
3037
- return header?.texts.get(key) ?? Reflect.get(source, key);
3038
- }
3039
- function censorAnyName(rules, name) {
3040
- if (typeof name === "string") return censorName(name, messageCensor(rules));
3041
- const holder = typeof name === "object" && name !== null || typeof name === "function";
3042
- return holder && rules.sensitive.has("message") ? rules.censor : name;
3043
- }
3044
- function scrubPlainStack(rules, stack, header) {
3045
- const texts = [...new Set(header?.texts.values())];
3046
- const longest = texts.reduce((most, text) => Math.max(most, text.length), 0);
3047
- const hidden = hideMessagesInStack(
3048
- // 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.
3049
- stack.slice(0, MAX_STACK_SCAN + longest),
3050
- texts,
3051
- rules.censor,
3052
- MAX_STACK_SCAN
3053
- );
3054
- return scrubStack(hidden, void 0, stack.length > MAX_STACK_SCAN);
3055
- }
3056
- function errorTextField(rules, key, value, isError2, header) {
3057
- const isStack = !isError2 && typeof value === "string" && (header === void 0 ? matchesKey(STACK_NAMES, key) : header.stackKeys.has(key));
3058
- if (isStack) {
3059
- return header?.overflow === true ? rules.censor : scrubPlainStack(rules, value, header);
3060
- }
3061
- if (!isError2 || !ERROR_TEXT_FIELDS.has(key)) return value;
3062
- const cut = cutIfText(value);
3063
- return key === "name" ? censorAnyName(rules, cut) : cut;
3064
- }
3065
-
3066
3416
  // src/server/utils/redact-error-clone.util.ts
3067
3417
  function shadowHook(target) {
3068
- Reflect.defineProperty(target, "toJSON", { value: void 0, configurable: true });
3418
+ Reflect.defineProperty(target, "toJSON", bareDescriptor({ value: void 0, configurable: true }));
3069
3419
  }
3070
3420
  function withoutEnumerableKeys(clone) {
3071
3421
  for (const key of Object.keys(clone)) Reflect.deleteProperty(clone, key);
3072
3422
  }
3073
3423
  function discardWrite() {
3074
3424
  }
3075
- function cloneError(error) {
3076
- const descriptors = Object.getOwnPropertyDescriptors(error);
3077
- for (const descriptor of Object.values(descriptors)) {
3425
+ function relaxedDescriptors(descriptors) {
3426
+ const relaxed = /* @__PURE__ */ Object.create(null);
3427
+ for (const key of Reflect.ownKeys(descriptors)) {
3428
+ const descriptor = bareDescriptor(Reflect.get(descriptors, key));
3078
3429
  descriptor.configurable = true;
3079
- if ("value" in descriptor) descriptor.writable = true;
3430
+ if (Object.hasOwn(descriptor, "value")) descriptor.writable = true;
3080
3431
  else descriptor.set ??= discardWrite;
3432
+ Reflect.set(relaxed, key, descriptor);
3081
3433
  }
3082
- const clone = Object.create(Object.getPrototypeOf(error), descriptors);
3434
+ return relaxed;
3435
+ }
3436
+ function cloneError(error) {
3437
+ const clone = Object.create(
3438
+ Object.getPrototypeOf(error),
3439
+ relaxedDescriptors(Object.getOwnPropertyDescriptors(error))
3440
+ );
3083
3441
  const { stack } = error;
3084
3442
  if (typeof stack === "string") {
3085
- Reflect.defineProperty(clone, "stack", { value: stack, enumerable: false, writable: true });
3443
+ Reflect.defineProperty(
3444
+ clone,
3445
+ "stack",
3446
+ bareDescriptor({ value: stack, enumerable: false, writable: true })
3447
+ );
3086
3448
  }
3087
3449
  withoutEnumerableKeys(clone);
3088
3450
  shadowHook(clone);
3089
3451
  return clone;
3090
3452
  }
3091
-
3092
- // src/server/utils/redact-by-name.util.ts
3093
- var RAW_HEADER_KEYS = /* @__PURE__ */ new Set(["rawheaders", "rawtrailers"]);
3094
- function censorHeaderArray(key, walked, rules) {
3095
- return matchesKey(RAW_HEADER_KEYS, key) && Array.isArray(walked) ? censorRawHeaders(walked, rules.headerNames, rules.censor) : walked;
3096
- }
3097
- var REDACT_MAX_TRAVERSAL_DEPTH = 100;
3098
- var REDACT_DEPTH_EXCEEDED = "[REDACTION_DEPTH_EXCEEDED]";
3099
- var REDACT_MAX_VISITS = 2e5;
3100
- var REDACT_BUDGET_EXCEEDED = "[REDACTION_BUDGET_EXCEEDED]";
3101
- var REDACT_CIRCULAR = "[Circular]";
3453
+ var MAX_PROTOTYPE_HOPS2 = 256;
3102
3454
  function resolveToJson(value, viaGet = false) {
3103
3455
  let candidate = viaGet ? Reflect.get(value, "toJSON") : void 0;
3104
3456
  let accessor = false;
3105
3457
  let proxied = false;
3106
3458
  let current = viaGet ? null : value;
3107
- while (current !== null) {
3459
+ for (let hops = 0; current !== null; hops++) {
3460
+ if (hops > MAX_PROTOTYPE_HOPS2) return { method: void 0, volatile: true, hostile: true };
3108
3461
  proxied = proxied || util.types.isProxy(current);
3109
3462
  const descriptor = Object.getOwnPropertyDescriptor(current, "toJSON");
3110
3463
  if (descriptor !== void 0) {
3111
- accessor = descriptor.get !== void 0;
3112
- candidate = descriptor.get === void 0 ? descriptor.value : descriptor.get.call(value);
3464
+ const getter = Object.hasOwn(descriptor, "get") ? descriptor.get : void 0;
3465
+ accessor = getter !== void 0;
3466
+ if (getter !== void 0) candidate = getter.call(value);
3467
+ else if (Object.hasOwn(descriptor, "value")) candidate = descriptor.value;
3113
3468
  break;
3114
3469
  }
3115
- current = Object.getPrototypeOf(current);
3470
+ const next = Object.getPrototypeOf(current);
3471
+ current = typeof next === "object" ? next : null;
3116
3472
  }
3117
3473
  return {
3118
3474
  method: typeof candidate === "function" ? candidate : void 0,
3119
3475
  volatile: accessor || proxied
3120
3476
  };
3121
3477
  }
3478
+
3479
+ // src/server/utils/redact-by-name.util.ts
3480
+ var RAW_HEADER_KEYS = capturedSet(["rawheaders", "rawtrailers"]);
3481
+ function censorHeaderArray(key, walked, rules) {
3482
+ return matchesKey(RAW_HEADER_KEYS, key) && Array.isArray(walked) ? censorRawHeaders(walked, rules.headerNames, rules.censor) : walked;
3483
+ }
3484
+ var REDACT_MAX_TRAVERSAL_DEPTH = 100;
3485
+ var REDACT_DEPTH_EXCEEDED = "[REDACTION_DEPTH_EXCEEDED]";
3486
+ var REDACT_MAX_VISITS = 2e5;
3487
+ var REDACT_BUDGET_EXCEEDED = "[REDACTION_BUDGET_EXCEEDED]";
3488
+ var REDACT_CIRCULAR = "[Circular]";
3122
3489
  function rulesInside(rules, names, visits) {
3123
3490
  return names === void 0 ? void 0 : { ...rules, sensitive: names, visits, insideErrors: void 0 };
3124
3491
  }
@@ -3155,7 +3522,7 @@ function walk(value, rules, depth2, ancestors, honorToJson, inSerialized = false
3155
3522
  if (++rules.visits.count > rules.maxVisits) {
3156
3523
  return REDACT_BUDGET_EXCEEDED;
3157
3524
  }
3158
- if (ancestors.has(value)) {
3525
+ if (setHas(ancestors, value)) {
3159
3526
  return REDACT_CIRCULAR;
3160
3527
  }
3161
3528
  if (isError(value)) {
@@ -3183,7 +3550,8 @@ function walkObject(value, rules, depth2, ancestors, honorToJson, inSerialized)
3183
3550
  return withBinaryAsSize(value);
3184
3551
  }
3185
3552
  const resolved = resolveToJson(value, rules.ownFields.safe);
3186
- ancestors.add(value);
3553
+ if (resolved.hostile) return rules.censor;
3554
+ setAdd(ancestors, value);
3187
3555
  try {
3188
3556
  return walkForm(value, resolved, rules, depth2, ancestors, honorToJson, inSerialized);
3189
3557
  } finally {
@@ -3223,7 +3591,7 @@ function walkProperties(value, rules, depth2, ancestors, honorToJson, inSerializ
3223
3591
  const current = scrubbed ? ownFieldForLog(source, key, read, rules.ownFields) : read;
3224
3592
  const hook = honorToJson && key === "toJSON" && typeof current === "function";
3225
3593
  if (current === OMIT_OWN_FIELD || hook) {
3226
- omitted.add(key);
3594
+ setAdd(omitted, key);
3227
3595
  continue;
3228
3596
  }
3229
3597
  Reflect.deleteProperty(copy, key);
@@ -3251,7 +3619,7 @@ function walkProperties(value, rules, depth2, ancestors, honorToJson, inSerializ
3251
3619
  return copy;
3252
3620
  }
3253
3621
  function without(keys, omitted) {
3254
- return keys.filter((key) => !omitted.has(key));
3622
+ return keys.filter((key) => !setHas(omitted, key));
3255
3623
  }
3256
3624
  function startCopy(value, asData) {
3257
3625
  const clone = isError(value) ? cloneError(value) : void 0;
@@ -3276,7 +3644,7 @@ function createNameRedactor(fieldNames, censor, serializedKeys, maxVisits = REDA
3276
3644
  sensitive: foldedNames(fieldNames),
3277
3645
  headerNames: foldedNames(headerNames ?? fieldNames),
3278
3646
  censor,
3279
- serializedKeys: new Set(serializedKeys),
3647
+ serializedKeys: capturedSet(serializedKeys),
3280
3648
  errorsAsData: serializedKeys !== void 0,
3281
3649
  errorTextToSerializer,
3282
3650
  maxVisits,
@@ -3286,13 +3654,13 @@ function createNameRedactor(fieldNames, censor, serializedKeys, maxVisits = REDA
3286
3654
  return (value, isRecordRoot = false) => {
3287
3655
  try {
3288
3656
  const visits = { count: 0 };
3289
- const call = {
3657
+ const call2 = {
3290
3658
  ...rules,
3291
3659
  headerKept: typeof value === "object" && value !== null && errorOutputs.has(value),
3292
3660
  visits,
3293
3661
  insideErrors: rulesInside(rules, insideNames, visits)
3294
3662
  };
3295
- return walk(value, call, 0, /* @__PURE__ */ new Set(), !isRecordRoot);
3663
+ return walk(value, call2, 0, /* @__PURE__ */ new Set(), !isRecordRoot);
3296
3664
  } catch {
3297
3665
  return {
3298
3666
  _redactionFailed: true,
@@ -3329,7 +3697,11 @@ function parseResourceAttributes(raw) {
3329
3697
  } catch {
3330
3698
  value = rawValue;
3331
3699
  }
3332
- Object.defineProperty(parsed, key, { value, enumerable: true, configurable: true });
3700
+ Object.defineProperty(
3701
+ parsed,
3702
+ key,
3703
+ bareDescriptor({ value, enumerable: true, configurable: true })
3704
+ );
3333
3705
  }
3334
3706
  return parsed;
3335
3707
  }
@@ -3406,7 +3778,7 @@ function buildResourceBindings(resolved, format, extras = {}) {
3406
3778
  }
3407
3779
  return bindings;
3408
3780
  }
3409
- var OWNED_SERVICE_KEYS = /* @__PURE__ */ new Set([
3781
+ var OWNED_SERVICE_KEYS = capturedSet([
3410
3782
  "name",
3411
3783
  "version",
3412
3784
  "namespace",
@@ -3553,9 +3925,9 @@ var PATH_SEGMENT = /\[\s*['"]([^'"]+)['"]\s*\]|([^.[\]]+)/g;
3553
3925
  var INDEX_SEGMENT = /^\d+$/;
3554
3926
  function leafNameOf(path) {
3555
3927
  let leaf;
3556
- for (const match of path.matchAll(PATH_SEGMENT)) {
3928
+ for (const match of allMatches(PATH_SEGMENT, path)) {
3557
3929
  const quoted = match[1];
3558
- const name = quoted ?? (match[2] !== void 0 && INDEX_SEGMENT.test(match[2]) ? void 0 : match[2]);
3930
+ const name = quoted ?? (match[2] !== void 0 && matchesPattern(INDEX_SEGMENT, match[2]) ? void 0 : match[2]);
3559
3931
  if (name !== void 0 && name !== "*") {
3560
3932
  leaf = name;
3561
3933
  }
@@ -3582,7 +3954,7 @@ function serializeErrorValue(value_, ownFields = ALL_OWN_FIELDS, censorMessage)
3582
3954
  return serialized;
3583
3955
  }
3584
3956
  function toEventName(logKey) {
3585
- return logKey.toLowerCase().replaceAll("_", ".");
3957
+ return replaceAllText(lowerCase(logKey), "_", ".");
3586
3958
  }
3587
3959
  function withEventName(record, field) {
3588
3960
  if (field === false) {
@@ -3607,7 +3979,7 @@ function resolveRecordRedactor(options) {
3607
3979
  );
3608
3980
  }
3609
3981
  function wholeRootKeys(options) {
3610
- return /* @__PURE__ */ new Set(["logKey", "err", ...Object.keys(options.serializers)]);
3982
+ return capturedSet(["logKey", "err", ...Object.keys(options.serializers)]);
3611
3983
  }
3612
3984
  function ownFieldPolicyOf(options) {
3613
3985
  return createOwnFieldPolicy(options.errorOwnFields, options.errorOwnFieldNames);
@@ -3646,7 +4018,7 @@ function buildNameRedactor(options, nestedErrorsAsData = false, coversNames = tr
3646
4018
  );
3647
4019
  }
3648
4020
  function resolveRedactOption(options) {
3649
- const paths = options.redactStrategy === "paths" ? compileRedactPaths(options.redactPaths, options.shouldDisableDefaultRedact) : [...new Set(options.redactPaths)];
4021
+ const paths = options.redactStrategy === "paths" ? compileRedactPaths(options.redactPaths, options.shouldDisableDefaultRedact) : [...capturedSet(options.redactPaths)];
3650
4022
  if (paths.length === 0) {
3651
4023
  return void 0;
3652
4024
  }
@@ -3689,6 +4061,10 @@ function buildTraceMixin(logContext, options) {
3689
4061
  censorMessage: buildMessageCensor(options)
3690
4062
  });
3691
4063
  }
4064
+ var UNSET_ENTRY_NAMES = {
4065
+ levelVal: void 0,
4066
+ write: void 0
4067
+ };
3692
4068
  function buildStreams(options, destinations, health) {
3693
4069
  const censorMessage = buildMessageCensor(options);
3694
4070
  return destinations.map((destination) => {
@@ -3700,6 +4076,7 @@ function buildStreams(options, destinations, health) {
3700
4076
  );
3701
4077
  health.registerStream(destination, stream);
3702
4078
  return {
4079
+ ...UNSET_ENTRY_NAMES,
3703
4080
  // Guarded: this runs at provider construction, BEFORE any lifecycle hook, so a
3704
4081
  // consumer implementing `minLevel` as a throwing getter would fail the factory
3705
4082
  // and the application would never start — earlier than any fail-soft path can
@@ -3756,10 +4133,24 @@ function buildFormatters(options, redactRecord, redactBindings, onTruncate) {
3756
4133
  log: buildRecordFormatter(options, redactRecord, onTruncate)
3757
4134
  };
3758
4135
  }
3759
- function buildPinoInstance(options, logContext, destinations, health) {
4136
+ var UNSET_PINO_NAMES = {
4137
+ transport: void 0,
4138
+ crlf: false,
4139
+ msgPrefix: void 0,
4140
+ name: void 0,
4141
+ writable: false,
4142
+ _writableState: void 0,
4143
+ prettyPrint: void 0,
4144
+ onChild: void 0
4145
+ };
4146
+ function refuseUnsafeOptions(options) {
4147
+ if (!pinoBuiltinsIntact()) throw new Error("LOGGER_BUILTINS_REPLACED");
3760
4148
  if (options.maxStringLength !== void 0) {
3761
4149
  refuseCensorBeyondLimit(options.redactCensor, options.maxStringLength);
3762
4150
  }
4151
+ }
4152
+ function buildPinoInstance(options, logContext, destinations, health) {
4153
+ refuseUnsafeOptions(options);
3763
4154
  const redactRecord = resolveRecordRedactor(options);
3764
4155
  const redactSerialized = buildNameRedactor(options);
3765
4156
  const ownFields = ownFieldPolicyOf(options);
@@ -3767,10 +4158,10 @@ function buildPinoInstance(options, logContext, destinations, health) {
3767
4158
  const onTruncate = (reason) => health.recordTruncation(reason);
3768
4159
  const pinoOptions = {
3769
4160
  level: options.level,
3770
- ...redactOption === void 0 ? {} : { redact: redactOption },
3771
- // Resource identity, resolved ONCE here rather than per entry: Pino
3772
- // pre-serializes `base` into the instance's chindings, so the cost of the
3773
- // extra attributes is one string built at construction, not work per log.
4161
+ ...redactOption === void 0 ? {} : { redact: { ...redactOption, remove: false } },
4162
+ ...UNSET_PINO_NAMES,
4163
+ // Resource identity, resolved ONCE here rather than per entry: Pino pre-serializes `base` into
4164
+ // the instance's chindings, so the extra attributes cost one string at construction.
3774
4165
  base: buildResourceBindings(
3775
4166
  resolveServiceMetadata(options.service),
3776
4167
  options.resourceFormat,
@@ -3809,7 +4200,7 @@ var DestinationHealth = class {
3809
4200
  this.entrySizeTruncations = 0;
3810
4201
  this.stringLengthTruncations = 0;
3811
4202
  /** Destinations whose `onInit()` rejected. Identity-keyed, not name-keyed. */
3812
- this.failed = /* @__PURE__ */ new Set();
4203
+ this.failed = capturedSet();
3813
4204
  /**
3814
4205
  * Destinations that initialized, each with its effective level as an index into
3815
4206
  * {@link LOG_LEVEL_PRIORITY}.
@@ -3835,7 +4226,7 @@ var DestinationHealth = class {
3835
4226
  * for the whole window — coarser than per-entry tracking, and wrong only in the
3836
4227
  * direction that duplicates rather than loses.
3837
4228
  */
3838
- this.writeFailed = /* @__PURE__ */ new Set();
4229
+ this.writeFailed = capturedSet();
3839
4230
  /**
3840
4231
  * In-flight asynchronous writes per destination.
3841
4232
  *
@@ -4091,20 +4482,21 @@ var HookTimeoutError = class extends Error {
4091
4482
  }
4092
4483
  };
4093
4484
  function withTimeout(work, ms) {
4094
- return new Promise((resolve, reject2) => {
4485
+ const wait = new IntrinsicPromise((resolve, reject2) => {
4095
4486
  const timer = setTimeout(() => {
4096
4487
  reject2(new HookTimeoutError(ms));
4097
4488
  }, ms);
4098
- const settle = (done) => (...args) => {
4099
- clearTimeout(timer);
4100
- done(...args);
4101
- };
4102
- try {
4103
- Promise.resolve(work()).then(settle(resolve), settle(reject2));
4104
- } catch (cause) {
4105
- settle(reject2)(cause);
4106
- }
4489
+ awaitOutcome(work, (outcome) => {
4490
+ if (outcome.ok) resolve();
4491
+ else reject2(outcome.cause);
4492
+ try {
4493
+ clearTimeout(timer);
4494
+ } catch {
4495
+ }
4496
+ });
4107
4497
  });
4498
+ absorb(wait);
4499
+ return tag(wait);
4108
4500
  }
4109
4501
 
4110
4502
  // src/server/services/destination-registry.service.ts
@@ -4154,7 +4546,9 @@ var DestinationRegistry = class {
4154
4546
  async onModuleInit() {
4155
4547
  for (const destination of this.registered) {
4156
4548
  try {
4157
- await withTimeout(() => destination.onInit?.(), this.options.destinationHookTimeoutMs);
4549
+ await intactOr(
4550
+ withTimeout(() => destination.onInit?.(), this.options.destinationHookTimeoutMs)
4551
+ );
4158
4552
  this.active.push(destination);
4159
4553
  this.health.markHealthy(destination, this.effectiveLevelOf(destination));
4160
4554
  } catch (cause) {
@@ -4186,14 +4580,16 @@ var DestinationRegistry = class {
4186
4580
  async notifyRegistryReady() {
4187
4581
  for (const destination of this.registered) {
4188
4582
  try {
4189
- await withTimeout(
4190
- () => destination.onRegistryReady?.({
4191
- heldEntriesDeliveredElsewhere: this.health.deliveredByHealthySink(
4192
- destination,
4193
- this.effectiveLevelOf(destination)
4194
- )
4195
- }),
4196
- this.options.destinationHookTimeoutMs
4583
+ await intactOr(
4584
+ withTimeout(
4585
+ () => destination.onRegistryReady?.({
4586
+ heldEntriesDeliveredElsewhere: this.health.deliveredByHealthySink(
4587
+ destination,
4588
+ this.effectiveLevelOf(destination)
4589
+ )
4590
+ }),
4591
+ this.options.destinationHookTimeoutMs
4592
+ )
4197
4593
  );
4198
4594
  } catch (cause) {
4199
4595
  this.reportHookFailure(destination, cause);
@@ -4335,7 +4731,7 @@ var DestinationRegistry = class {
4335
4731
  continue;
4336
4732
  }
4337
4733
  try {
4338
- await withTimeout(() => destination.onShutdown?.(), remaining);
4734
+ await intactOr(withTimeout(() => destination.onShutdown?.(), remaining));
4339
4735
  } catch (cause) {
4340
4736
  this.reportShutdownFailure(destination, cause);
4341
4737
  }
@@ -4714,7 +5110,7 @@ function productionRefusal() {
4714
5110
  );
4715
5111
  }
4716
5112
  async function buildTransform(view) {
4717
- const { build } = await import('pino-pretty');
5113
+ const { build } = await tag(import('pino-pretty'));
4718
5114
  return build({
4719
5115
  ...DEFAULT_VIEW,
4720
5116
  ...view,
@@ -4791,7 +5187,7 @@ var PrettyDevDestination = class {
4791
5187
  throw productionRefusal();
4792
5188
  }
4793
5189
  try {
4794
- this.stream = await buildTransform(this.view);
5190
+ this.stream = await tag(buildTransform(this.view));
4795
5191
  } catch (cause) {
4796
5192
  this.initFailed = true;
4797
5193
  throw initFailure(cause);