@bymax-one/nest-logger 1.4.27 → 1.4.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +80 -1
- package/README.md +16 -14
- package/dist/server/index.cjs +260 -105
- package/dist/server/index.mjs +260 -105
- package/package.json +1 -1
package/dist/server/index.mjs
CHANGED
|
@@ -22,6 +22,23 @@ var __decorateParam = (index, decorator) => (target, key) => decorator(target, k
|
|
|
22
22
|
var getFilename = () => fileURLToPath(import.meta.url);
|
|
23
23
|
var __filename$1 = /* @__PURE__ */ getFilename();
|
|
24
24
|
|
|
25
|
+
// src/server/config/options-refusal.util.ts
|
|
26
|
+
var refusals = /* @__PURE__ */ new WeakSet();
|
|
27
|
+
var UNREADABLE = "[BymaxLoggerModule] options could not be read";
|
|
28
|
+
function refuse(message) {
|
|
29
|
+
const error = new Error(message);
|
|
30
|
+
refusals.add(error);
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
function guardOptions(read) {
|
|
34
|
+
try {
|
|
35
|
+
return read();
|
|
36
|
+
} catch (error) {
|
|
37
|
+
if (typeof error === "object" && error !== null && refusals.delete(error)) throw error;
|
|
38
|
+
throw new Error(UNREADABLE, { cause: error });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
25
42
|
// src/server/config/drop-unset-options.ts
|
|
26
43
|
var OPTION_KEYS = {
|
|
27
44
|
service: true,
|
|
@@ -78,6 +95,29 @@ function readSet(source, keys) {
|
|
|
78
95
|
}
|
|
79
96
|
return set;
|
|
80
97
|
}
|
|
98
|
+
var LIST_OPTIONS = ["redactPaths", "errorOwnFieldNames", "destinations"];
|
|
99
|
+
var HTTP_LISTS = ["excludePaths", "secretPathSegments"];
|
|
100
|
+
var MAX_LIST_ENTRIES = 1e4;
|
|
101
|
+
function copyLists(holder, names, prefix) {
|
|
102
|
+
for (const name of names) {
|
|
103
|
+
const value = Reflect.get(holder, name);
|
|
104
|
+
if (!Array.isArray(value)) continue;
|
|
105
|
+
const length = Reflect.get(value, "length");
|
|
106
|
+
if (!Number.isInteger(length) || length < 0) {
|
|
107
|
+
refuse(`[BymaxLoggerModule] options.${prefix}${name} has a length that is not a count`);
|
|
108
|
+
}
|
|
109
|
+
if (length > MAX_LIST_ENTRIES) {
|
|
110
|
+
refuse(
|
|
111
|
+
`[BymaxLoggerModule] options.${prefix}${name} holds more than ${String(MAX_LIST_ENTRIES)} entries`
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
Reflect.set(
|
|
115
|
+
holder,
|
|
116
|
+
name,
|
|
117
|
+
Array.from({ length }, (_, index) => Reflect.get(value, index))
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
81
121
|
function dropUnsetOptions(options) {
|
|
82
122
|
if (!isRecord(options)) return options;
|
|
83
123
|
const set = readSet(options, Object.keys(OPTION_KEYS));
|
|
@@ -86,6 +126,13 @@ function dropUnsetOptions(options) {
|
|
|
86
126
|
if (isRecord(value))
|
|
87
127
|
Reflect.set(set, group, readSet(value, Object.keys(Reflect.get(GROUP_KEYS, group))));
|
|
88
128
|
}
|
|
129
|
+
const service = Reflect.get(set, "service");
|
|
130
|
+
if (isRecord(service)) Reflect.set(set, "service", { ...service });
|
|
131
|
+
const serializers = Reflect.get(set, "serializers");
|
|
132
|
+
if (isRecord(serializers)) Reflect.set(set, "serializers", { ...serializers });
|
|
133
|
+
copyLists(set, LIST_OPTIONS, "");
|
|
134
|
+
const http = Reflect.get(set, "http");
|
|
135
|
+
if (isRecord(http)) copyLists(http, HTTP_LISTS, "http.");
|
|
89
136
|
return set;
|
|
90
137
|
}
|
|
91
138
|
|
|
@@ -183,23 +230,6 @@ function applyDefaults(given) {
|
|
|
183
230
|
return Object.freeze(merged);
|
|
184
231
|
}
|
|
185
232
|
|
|
186
|
-
// src/server/config/options-refusal.util.ts
|
|
187
|
-
var refusals = /* @__PURE__ */ new WeakSet();
|
|
188
|
-
var UNREADABLE = "[BymaxLoggerModule] options could not be read";
|
|
189
|
-
function refuse(message) {
|
|
190
|
-
const error = new Error(message);
|
|
191
|
-
refusals.add(error);
|
|
192
|
-
throw error;
|
|
193
|
-
}
|
|
194
|
-
function guardOptions(read) {
|
|
195
|
-
try {
|
|
196
|
-
return read();
|
|
197
|
-
} catch (error) {
|
|
198
|
-
if (typeof error === "object" && error !== null && refusals.delete(error)) throw error;
|
|
199
|
-
throw new Error(UNREADABLE, { cause: error });
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
233
|
// src/server/constants/log-levels.constants.ts
|
|
204
234
|
var PINO_LEVEL_NUMBERS = Object.freeze({
|
|
205
235
|
fatal: 60,
|
|
@@ -498,6 +528,15 @@ function validateOptions(given) {
|
|
|
498
528
|
validateOtel(options);
|
|
499
529
|
}
|
|
500
530
|
|
|
531
|
+
// src/server/config/resolve-options.ts
|
|
532
|
+
function resolveOptions(given) {
|
|
533
|
+
return guardOptions(() => {
|
|
534
|
+
const snapshot = dropUnsetOptions(given);
|
|
535
|
+
validateOptions(snapshot);
|
|
536
|
+
return applyDefaults(snapshot);
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
|
|
501
540
|
// src/server/constants/injection-tokens.constants.ts
|
|
502
541
|
var LOGGER_OPTIONS_TOKEN = /* @__PURE__ */ Symbol("BYMAX_LOGGER_OPTIONS");
|
|
503
542
|
var LOGGER_PINO_INSTANCE_TOKEN = /* @__PURE__ */ Symbol("BYMAX_LOGGER_PINO_INSTANCE");
|
|
@@ -617,47 +656,141 @@ function escapeControlCharacters(text) {
|
|
|
617
656
|
}
|
|
618
657
|
|
|
619
658
|
// src/server/utils/fold-key.util.ts
|
|
620
|
-
var
|
|
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;
|
|
621
662
|
var PLAIN = /^[\x21-\x7e]*$/;
|
|
663
|
+
var NON_ASCII = /[^\x20-\x7e]/;
|
|
664
|
+
var NOT_ASCII_NAME = /[^A-Za-z0-9]/g;
|
|
622
665
|
var LOOKALIKES = new Map(
|
|
623
666
|
Object.entries({
|
|
624
667
|
a: "\u0430\u03B1\u1D00",
|
|
625
668
|
b: "\u0299",
|
|
626
|
-
c: "\u0441\u03F2\u1D04",
|
|
669
|
+
c: "\u0441\u03F2\u1D04\u023C\u0188",
|
|
627
670
|
d: "\u0501\u1D05",
|
|
628
|
-
e: "\u0435\u03B5\u03F5\u1D07",
|
|
671
|
+
e: "\u0435\u03B5\u03F5\u1D07\u025B\u04BD",
|
|
629
672
|
f: "\uA730",
|
|
630
673
|
g: "\u0262",
|
|
631
674
|
h: "\u029C",
|
|
632
|
-
i: "\u0456\u03B9\u0131\u026A",
|
|
633
675
|
j: "\u0458\u1D0A",
|
|
634
676
|
k: "\u1D0B",
|
|
635
677
|
l: "\u029F",
|
|
636
678
|
m: "\u1D0D",
|
|
637
679
|
n: "\u0274",
|
|
638
|
-
o: "\u043E\u03BF\u1D0F",
|
|
639
|
-
p: "\u0440\u03C1\u1D18",
|
|
680
|
+
o: "\u043E\u03BF\u1D0F\xF8",
|
|
681
|
+
p: "\u0440\u03C1\u1D18\u01BF",
|
|
640
682
|
q: "\u051B",
|
|
641
683
|
r: "\u0280",
|
|
642
684
|
s: "\u0455\uA731",
|
|
643
|
-
t: "\u1D1B",
|
|
685
|
+
t: "\u1D1B\u0167",
|
|
644
686
|
u: "\u1D1C",
|
|
645
|
-
v: "\
|
|
687
|
+
v: "\u1D20",
|
|
646
688
|
w: "\u051D\u1D21",
|
|
647
689
|
x: "\u0445",
|
|
648
|
-
y: "\u0443\u028F",
|
|
690
|
+
y: "\u0443\u028F\u04AF",
|
|
649
691
|
z: "\u1D22"
|
|
650
692
|
}).flatMap(([latin, letters]) => [...letters].map((letter) => [letter, latin]))
|
|
651
693
|
);
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
694
|
+
var I_LIKE = new Map(
|
|
695
|
+
[..."\u0456\u03B9\u0131\u026A\u0269"].map((letter) => [letter, "i"])
|
|
696
|
+
);
|
|
697
|
+
function foldKey(key, keepSeparators = false) {
|
|
698
|
+
if (keepSeparators) {
|
|
699
|
+
if (PLAIN.test(key)) return key.toLowerCase();
|
|
700
|
+
return withLookalikes(
|
|
701
|
+
key.normalize("NFKD").toLowerCase().replace(DOTS, ".").replace(INVISIBLE, ""),
|
|
702
|
+
true
|
|
703
|
+
);
|
|
704
|
+
}
|
|
705
|
+
if (PLAIN.test(key)) return key.replace(NOT_ASCII_NAME, "").toLowerCase();
|
|
706
|
+
return withLookalikes(key.normalize("NFKD").toLowerCase().replace(NOT_NAME, ""), true);
|
|
707
|
+
}
|
|
708
|
+
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);
|
|
711
|
+
}
|
|
712
|
+
function withLookalikes(folded, all) {
|
|
713
|
+
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);
|
|
716
|
+
return read;
|
|
717
|
+
}
|
|
718
|
+
var ALNUM = /^[A-Za-z0-9]*$/;
|
|
719
|
+
function formOf(key) {
|
|
720
|
+
return ALNUM.test(key) ? key.toLowerCase() : foldStrict(key);
|
|
721
|
+
}
|
|
722
|
+
var answers = /* @__PURE__ */ new WeakMap();
|
|
723
|
+
function foldName(key) {
|
|
724
|
+
return formOf(key);
|
|
725
|
+
}
|
|
726
|
+
function foldedNames(names) {
|
|
727
|
+
return new Set(Array.from(names, foldName).filter((name) => name !== ""));
|
|
728
|
+
}
|
|
729
|
+
var MAX_CANDIDATES = 64;
|
|
730
|
+
var grouped = /* @__PURE__ */ new WeakMap();
|
|
731
|
+
function groupsOf(names) {
|
|
732
|
+
let groups = grouped.get(names);
|
|
733
|
+
if (groups === void 0) {
|
|
734
|
+
const built = /* @__PURE__ */ new Map();
|
|
735
|
+
let longest = 0;
|
|
736
|
+
for (const name of names) {
|
|
737
|
+
const size = [...name].length;
|
|
738
|
+
const same = built.get(size);
|
|
739
|
+
if (same === void 0) built.set(size, [name]);
|
|
740
|
+
else same.push(name);
|
|
741
|
+
longest = Math.max(longest, size);
|
|
742
|
+
}
|
|
743
|
+
groups = { byLength: built, longest };
|
|
744
|
+
grouped.set(names, groups);
|
|
745
|
+
}
|
|
746
|
+
return groups;
|
|
747
|
+
}
|
|
748
|
+
function matchesFolded(names, folded) {
|
|
749
|
+
if (names.has(folded)) return true;
|
|
750
|
+
if (!NON_ASCII.test(folded)) return false;
|
|
751
|
+
const letters = [...folded];
|
|
752
|
+
const wide = letters.filter((letter) => !isAscii(letter)).length;
|
|
753
|
+
const { byLength, longest } = groupsOf(names);
|
|
754
|
+
if (letters.length > longest) return false;
|
|
755
|
+
const lengths = Array.from(
|
|
756
|
+
{ length: wide + 1 },
|
|
757
|
+
(_, extra) => byLength.get(letters.length + extra) ?? []
|
|
758
|
+
);
|
|
759
|
+
if (lengths.reduce((count, same) => count + same.length, 0) > MAX_CANDIDATES) return true;
|
|
760
|
+
return lengths.some((same) => same.some((name) => matchesName(letters, [...name])));
|
|
761
|
+
}
|
|
762
|
+
var isAscii = (letter) => letter < "\x80";
|
|
763
|
+
function matchesName(letters, name) {
|
|
764
|
+
let at = /* @__PURE__ */ new Set([0]);
|
|
765
|
+
for (const letter of letters) {
|
|
766
|
+
const next = /* @__PURE__ */ new Set();
|
|
767
|
+
for (const position of at) {
|
|
768
|
+
if (isAscii(letter)) {
|
|
769
|
+
if (name[position] === letter) next.add(position + 1);
|
|
770
|
+
continue;
|
|
771
|
+
}
|
|
772
|
+
next.add(position + 1);
|
|
773
|
+
next.add(position + 2);
|
|
774
|
+
}
|
|
775
|
+
at = next;
|
|
776
|
+
}
|
|
777
|
+
return at.has(name.length);
|
|
778
|
+
}
|
|
779
|
+
function matchesKey(names, key) {
|
|
780
|
+
const seen = answers.get(names) ?? /* @__PURE__ */ new Map();
|
|
781
|
+
answers.set(names, seen);
|
|
782
|
+
const known = seen.get(key);
|
|
783
|
+
if (known !== void 0) return known;
|
|
784
|
+
const folded = formOf(key);
|
|
785
|
+
const answer = names.has(folded) || matchesFolded(names, folded);
|
|
786
|
+
if (key.length <= 64) {
|
|
787
|
+
if (seen.size > 1023) seen.clear();
|
|
788
|
+
seen.set(key, answer);
|
|
789
|
+
}
|
|
790
|
+
return answer;
|
|
657
791
|
}
|
|
658
792
|
|
|
659
793
|
// src/server/utils/hide-message-in-stack.util.ts
|
|
660
|
-
var FRAME_LINE = /\n[ \t]+at /g;
|
|
661
794
|
function failureTable(message) {
|
|
662
795
|
const table = new Int32Array(message.length);
|
|
663
796
|
for (let i = 1, matched = 0; i < message.length; i += 1) {
|
|
@@ -668,41 +801,38 @@ function failureTable(message) {
|
|
|
668
801
|
return table;
|
|
669
802
|
}
|
|
670
803
|
function occurrences(stack, message) {
|
|
804
|
+
if (message.length > stack.length) return [];
|
|
671
805
|
const table = failureTable(message);
|
|
672
806
|
const spans = [];
|
|
673
807
|
for (let i = 0, matched = 0; i < stack.length; i += 1) {
|
|
674
808
|
while (matched > 0 && stack[i] !== message[matched]) matched = table[matched - 1];
|
|
675
809
|
if (stack[i] === message[matched]) matched += 1;
|
|
676
810
|
if (matched === message.length) {
|
|
677
|
-
|
|
678
|
-
const last = spans[spans.length - 1];
|
|
679
|
-
if (last !== void 0 && start < last[1]) last[1] = i + 1;
|
|
680
|
-
else spans.push([start, i + 1]);
|
|
811
|
+
spans.push([i + 1 - message.length, i + 1]);
|
|
681
812
|
}
|
|
682
813
|
}
|
|
683
814
|
return spans;
|
|
684
815
|
}
|
|
685
|
-
function
|
|
686
|
-
|
|
687
|
-
for (const line of stack.matchAll(FRAME_LINE)) {
|
|
688
|
-
while (next < spans.length && spans[next][1] <= line.index) next += 1;
|
|
689
|
-
const span = spans[next];
|
|
690
|
-
if (span === void 0 || line.index < span[0]) return line.index;
|
|
691
|
-
}
|
|
692
|
-
return stack.length;
|
|
693
|
-
}
|
|
694
|
-
function hideMessageInStack(stack, message, replacement) {
|
|
695
|
-
if (message === "") return stack;
|
|
696
|
-
if (message.length > stack.length) return stack;
|
|
697
|
-
const spans = occurrences(stack, message);
|
|
698
|
-
const end = headerEnd(stack, spans);
|
|
816
|
+
function hideMessagesInStack(stack, messages, replacement, limit) {
|
|
817
|
+
const spans = messages.filter((message) => message !== "").flatMap((message) => occurrences(stack, message)).sort((a, b) => a[0] - b[0]);
|
|
699
818
|
let result = "";
|
|
700
819
|
let from = 0;
|
|
701
|
-
|
|
820
|
+
let end = limit;
|
|
821
|
+
for (const [start, stop] of spans) {
|
|
822
|
+
if (start >= end) break;
|
|
823
|
+
if (start < from) {
|
|
824
|
+
from = Math.max(from, stop);
|
|
825
|
+
end = Math.max(end, from);
|
|
826
|
+
continue;
|
|
827
|
+
}
|
|
702
828
|
result += stack.slice(from, start) + replacement;
|
|
703
829
|
from = stop;
|
|
830
|
+
end = Math.max(end, stop);
|
|
704
831
|
}
|
|
705
|
-
return result + stack.slice(from);
|
|
832
|
+
return result + stack.slice(from, Math.max(end, from));
|
|
833
|
+
}
|
|
834
|
+
function hideMessageInStack(stack, message, replacement) {
|
|
835
|
+
return hideMessagesInStack(stack, [message], replacement, stack.length);
|
|
706
836
|
}
|
|
707
837
|
|
|
708
838
|
// src/server/utils/is-plain-record.util.ts
|
|
@@ -721,17 +851,17 @@ function endsHeader(stack, message, from) {
|
|
|
721
851
|
const end = from + message.length;
|
|
722
852
|
return stack.startsWith(message, from) && (end === stack.length || stack.startsWith("\n", end));
|
|
723
853
|
}
|
|
724
|
-
function
|
|
725
|
-
if (message === "" || censored === message) return stack;
|
|
854
|
+
function splitCensoredHeader(stack, name, message, censored) {
|
|
855
|
+
if (message === "" || censored === message) return ["", stack];
|
|
726
856
|
const separator = stack.indexOf(NAME_SEPARATOR);
|
|
727
857
|
if (separator !== -1 && stack.lastIndexOf("\n", separator) === -1) {
|
|
728
858
|
const from = separator + NAME_SEPARATOR.length;
|
|
729
859
|
if (endsHeader(stack, message, from)) {
|
|
730
|
-
return stack.slice(0, from) + censored
|
|
860
|
+
return [stack.slice(0, from) + censored, stack.slice(from + message.length)];
|
|
731
861
|
}
|
|
732
862
|
}
|
|
733
|
-
if (endsHeader(stack, message, 0)) return censored
|
|
734
|
-
return name === "" ? censored : name + NAME_SEPARATOR + censored;
|
|
863
|
+
if (endsHeader(stack, message, 0)) return [censored, stack.slice(message.length)];
|
|
864
|
+
return [name === "" ? censored : name + NAME_SEPARATOR + censored, ""];
|
|
735
865
|
}
|
|
736
866
|
function isError(value) {
|
|
737
867
|
try {
|
|
@@ -818,14 +948,15 @@ function readScrubbedStack(value, name, message, textName, result, walk2) {
|
|
|
818
948
|
const stack = readOptional(() => value.stack, result);
|
|
819
949
|
if (stack === void 0) return void 0;
|
|
820
950
|
const header = headerCensor(name, message, walk2.censorMessage);
|
|
821
|
-
return
|
|
951
|
+
return textName ? scrubStack(stack, header) : scrubStack(withNamedHeader(stack, message), header, stack.length > MAX_STACK_SCAN);
|
|
822
952
|
}
|
|
823
|
-
var
|
|
953
|
+
var FRAME_LINE = /\n[ \t]+at /;
|
|
824
954
|
function withNamedHeader(stack, message) {
|
|
825
|
-
const
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
const
|
|
955
|
+
const head = stack.slice(0, MAX_STACK_SCAN);
|
|
956
|
+
const found = message === "" ? -1 : head.indexOf(message);
|
|
957
|
+
if (found !== -1) return `Error: ${head.slice(found)}`;
|
|
958
|
+
const end = head.search(FRAME_LINE);
|
|
959
|
+
const frames = end === -1 ? "" : head.slice(end);
|
|
829
960
|
return `Error${message === "" ? "" : `: ${message}`}${frames}`;
|
|
830
961
|
}
|
|
831
962
|
function toSanitizedError(value, seen, depth2, walk2) {
|
|
@@ -953,17 +1084,26 @@ function headerCensor(name, message, censorMessage) {
|
|
|
953
1084
|
function censorStackName(stack, header) {
|
|
954
1085
|
return header.name !== "" && stack.startsWith(header.name) ? header.censoredName + stack.slice(header.name.length) : stack;
|
|
955
1086
|
}
|
|
956
|
-
function
|
|
957
|
-
const
|
|
1087
|
+
function censorMessageInStack(stack, header) {
|
|
1088
|
+
const [opened, rest] = splitCensoredHeader(
|
|
1089
|
+
censorStackName(stack, header),
|
|
1090
|
+
header.censoredName,
|
|
1091
|
+
header.message,
|
|
1092
|
+
header.censored
|
|
1093
|
+
);
|
|
1094
|
+
return header.censored === header.message ? opened + rest : opened + hideMessagesInStack(
|
|
1095
|
+
rest,
|
|
1096
|
+
[header.message],
|
|
1097
|
+
header.censored,
|
|
1098
|
+
Math.max(0, MAX_STACK_SCAN - (stack.length - rest.length))
|
|
1099
|
+
);
|
|
1100
|
+
}
|
|
1101
|
+
function scrubStack(stack, header, wasLonger = false) {
|
|
1102
|
+
const window = stack.slice(0, MAX_STACK_SCAN + (header?.message.length ?? 0));
|
|
958
1103
|
const scrubbed = escapeControlCharacters(
|
|
959
|
-
(header === void 0 ?
|
|
960
|
-
censorStackName(head, header),
|
|
961
|
-
header.censoredName,
|
|
962
|
-
header.message,
|
|
963
|
-
header.censored
|
|
964
|
-
)).split("\n").filter((line) => !line.includes("node_modules")).join("\n")
|
|
1104
|
+
(header === void 0 ? window : censorMessageInStack(window, header)).slice(0, MAX_STACK_SCAN).split("\n").filter((line) => !line.includes("node_modules")).join("\n")
|
|
965
1105
|
);
|
|
966
|
-
return cutText(scrubbed, stack.length > MAX_STACK_SCAN);
|
|
1106
|
+
return cutText(scrubbed, wasLonger || stack.length > MAX_STACK_SCAN);
|
|
967
1107
|
}
|
|
968
1108
|
function isObject(value) {
|
|
969
1109
|
return typeof value === "object" && value !== null;
|
|
@@ -986,7 +1126,7 @@ var RESOURCE_KEYS = [
|
|
|
986
1126
|
"deployment.environment.name"
|
|
987
1127
|
];
|
|
988
1128
|
var OWNED_KEY_SPELLINGS = new Set(
|
|
989
|
-
[...OWNED_PAYLOAD_KEYS, ...ENTRY_STRUCTURE_KEYS, ...RESOURCE_KEYS].map(foldKey)
|
|
1129
|
+
[...OWNED_PAYLOAD_KEYS, ...ENTRY_STRUCTURE_KEYS, ...RESOURCE_KEYS].map((key) => foldKey(key))
|
|
990
1130
|
);
|
|
991
1131
|
var DERIVED_KEYS = /* @__PURE__ */ new Set([
|
|
992
1132
|
"exception.type",
|
|
@@ -994,10 +1134,9 @@ var DERIVED_KEYS = /* @__PURE__ */ new Set([
|
|
|
994
1134
|
"exception.stacktrace",
|
|
995
1135
|
"error.type"
|
|
996
1136
|
]);
|
|
997
|
-
var lookAlike = (key) => key.normalize("NFKC").replace(/[\p{Cf}\p{Zs}]/gu, "").toLowerCase();
|
|
998
1137
|
var isOwnedKey = (key) => {
|
|
999
1138
|
const lower = key.toLowerCase();
|
|
1000
|
-
return OWNED_KEY_SPELLINGS.has(foldKey(key)) || DERIVED_KEYS.has(
|
|
1139
|
+
return OWNED_KEY_SPELLINGS.has(foldKey(key)) || DERIVED_KEYS.has(foldKey(key, true)) || lower.startsWith("service.") || lower.startsWith("deployment.");
|
|
1001
1140
|
};
|
|
1002
1141
|
function withoutOwnedKeys(metadata, omit) {
|
|
1003
1142
|
if (metadata === void 0) {
|
|
@@ -2754,7 +2893,7 @@ function mergeMixinSafely(mergeObject, mixinObject) {
|
|
|
2754
2893
|
function censorRawHeaders(raw, sensitive, censor) {
|
|
2755
2894
|
return raw.map((entry, index) => {
|
|
2756
2895
|
const name = index % 2 === 1 ? raw[index - 1] : void 0;
|
|
2757
|
-
return typeof name === "string" && sensitive
|
|
2896
|
+
return typeof name === "string" && matchesKey(sensitive, name) ? censor : entry;
|
|
2758
2897
|
});
|
|
2759
2898
|
}
|
|
2760
2899
|
|
|
@@ -2864,34 +3003,57 @@ function rulesBelow(rules, key, value, honorToJson) {
|
|
|
2864
3003
|
return rules.exemptKeys === void 0 && rules.headerKept !== true ? rules : { ...rules, exemptKeys: void 0, headerKept: void 0 };
|
|
2865
3004
|
}
|
|
2866
3005
|
function isCensored(rules, key, value) {
|
|
2867
|
-
|
|
2868
|
-
return rules.sensitive.has(lower) && !(typeof value === "string" && rules.exemptKeys?.has(lower));
|
|
3006
|
+
return matchesKey(rules.sensitive, key) && !(typeof value === "string" && rules.exemptKeys?.has(key));
|
|
2869
3007
|
}
|
|
2870
3008
|
function messageCensor(rules) {
|
|
2871
3009
|
return (text) => rules.sensitive.has("message") ? rules.censor : text;
|
|
2872
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 };
|
|
2873
3015
|
function headerMessage(rules, source, keys, isError2) {
|
|
2874
|
-
if (isError2
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
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);
|
|
2880
3029
|
}
|
|
2881
|
-
const
|
|
2882
|
-
return
|
|
3030
|
+
const overflow = stacks.length > MAX_STACK_ALIASES || new Set(texts.values()).size > MAX_STACK_ALIASES;
|
|
3031
|
+
return { texts, stackKeys: new Set(stacks), overflow };
|
|
2883
3032
|
}
|
|
2884
3033
|
function readField(source, key, header) {
|
|
2885
|
-
return header
|
|
3034
|
+
return header?.texts.get(key) ?? Reflect.get(source, key);
|
|
2886
3035
|
}
|
|
2887
3036
|
function censorAnyName(rules, name) {
|
|
2888
3037
|
if (typeof name === "string") return censorName(name, messageCensor(rules));
|
|
2889
3038
|
const holder = typeof name === "object" && name !== null || typeof name === "function";
|
|
2890
3039
|
return holder && rules.sensitive.has("message") ? rules.censor : name;
|
|
2891
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
|
+
}
|
|
2892
3053
|
function errorTextField(rules, key, value, isError2, header) {
|
|
2893
|
-
|
|
2894
|
-
|
|
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);
|
|
2895
3057
|
}
|
|
2896
3058
|
if (!isError2 || !ERROR_TEXT_FIELDS.has(key)) return value;
|
|
2897
3059
|
const cut = cutIfText(value);
|
|
@@ -2927,7 +3089,7 @@ function cloneError(error) {
|
|
|
2927
3089
|
// src/server/utils/redact-by-name.util.ts
|
|
2928
3090
|
var RAW_HEADER_KEYS = /* @__PURE__ */ new Set(["rawheaders", "rawtrailers"]);
|
|
2929
3091
|
function censorHeaderArray(key, walked, rules) {
|
|
2930
|
-
return RAW_HEADER_KEYS
|
|
3092
|
+
return matchesKey(RAW_HEADER_KEYS, key) && Array.isArray(walked) ? censorRawHeaders(walked, rules.headerNames, rules.censor) : walked;
|
|
2931
3093
|
}
|
|
2932
3094
|
var REDACT_MAX_TRAVERSAL_DEPTH = 100;
|
|
2933
3095
|
var REDACT_DEPTH_EXCEEDED = "[REDACTION_DEPTH_EXCEEDED]";
|
|
@@ -3040,7 +3202,7 @@ function walkForm(value, resolved, rules, depth2, ancestors, honorToJson, inSeri
|
|
|
3040
3202
|
return walkProperties(value, rules, depth2, ancestors, honorToJson, inSerialized);
|
|
3041
3203
|
}
|
|
3042
3204
|
function walkToJsonOutput(value, toJson, rules, depth2, ancestors, inSerialized) {
|
|
3043
|
-
if (Object.keys(value).some((key) => rules.sensitive
|
|
3205
|
+
if (Object.keys(value).some((key) => matchesKey(rules.sensitive, key))) {
|
|
3044
3206
|
return rules.censor;
|
|
3045
3207
|
}
|
|
3046
3208
|
return walk(toJson.call(value), rules, depth2 + 1, ancestors, true, inSerialized);
|
|
@@ -3108,8 +3270,8 @@ function errorPartsHost(rules, ancestors, inSerialized) {
|
|
|
3108
3270
|
}
|
|
3109
3271
|
function createNameRedactor(fieldNames, censor, serializedKeys, maxVisits = REDACT_MAX_VISITS, ownFields = ALL_OWN_FIELDS, errorOnlyNames, headerNames, errorTextToSerializer = false) {
|
|
3110
3272
|
const rules = {
|
|
3111
|
-
sensitive:
|
|
3112
|
-
headerNames:
|
|
3273
|
+
sensitive: foldedNames(fieldNames),
|
|
3274
|
+
headerNames: foldedNames(headerNames ?? fieldNames),
|
|
3113
3275
|
censor,
|
|
3114
3276
|
serializedKeys: new Set(serializedKeys),
|
|
3115
3277
|
errorsAsData: serializedKeys !== void 0,
|
|
@@ -3117,7 +3279,7 @@ function createNameRedactor(fieldNames, censor, serializedKeys, maxVisits = REDA
|
|
|
3117
3279
|
maxVisits,
|
|
3118
3280
|
ownFields
|
|
3119
3281
|
};
|
|
3120
|
-
const insideNames = errorOnlyNames === void 0 ? void 0 :
|
|
3282
|
+
const insideNames = errorOnlyNames === void 0 ? void 0 : foldedNames(errorOnlyNames);
|
|
3121
3283
|
return (value, isRecordRoot = false) => {
|
|
3122
3284
|
try {
|
|
3123
3285
|
const visits = { count: 0 };
|
|
@@ -4401,10 +4563,8 @@ var BymaxLoggerModule = class extends BymaxLoggerModuleBase {
|
|
|
4401
4563
|
* BymaxLoggerModule.forRoot({ service: { name: 'api', version: '1.0.0' } })
|
|
4402
4564
|
*/
|
|
4403
4565
|
static forRoot(options) {
|
|
4404
|
-
const
|
|
4405
|
-
|
|
4406
|
-
return applyDefaults(options);
|
|
4407
|
-
});
|
|
4566
|
+
const snapshot = guardOptions(() => dropUnsetOptions(options));
|
|
4567
|
+
const resolved = resolveOptions(snapshot);
|
|
4408
4568
|
const providers = [
|
|
4409
4569
|
{ provide: LOGGER_OPTIONS_TOKEN, useValue: resolved },
|
|
4410
4570
|
...buildCommonProviders()
|
|
@@ -4416,7 +4576,7 @@ var BymaxLoggerModule = class extends BymaxLoggerModuleBase {
|
|
|
4416
4576
|
}
|
|
4417
4577
|
}
|
|
4418
4578
|
return augmentLoggerModule(
|
|
4419
|
-
guardOptions(() => super.forRoot(
|
|
4579
|
+
guardOptions(() => super.forRoot(snapshot)),
|
|
4420
4580
|
providers
|
|
4421
4581
|
);
|
|
4422
4582
|
}
|
|
@@ -4447,12 +4607,7 @@ var BymaxLoggerModule = class extends BymaxLoggerModuleBase {
|
|
|
4447
4607
|
const providers = [
|
|
4448
4608
|
{
|
|
4449
4609
|
provide: LOGGER_OPTIONS_TOKEN,
|
|
4450
|
-
useFactory: (raw) =>
|
|
4451
|
-
return guardOptions(() => {
|
|
4452
|
-
validateOptions(raw);
|
|
4453
|
-
return applyDefaults(raw);
|
|
4454
|
-
});
|
|
4455
|
-
},
|
|
4610
|
+
useFactory: (raw) => resolveOptions(raw),
|
|
4456
4611
|
inject: [BUILDER_OPTIONS_TOKEN]
|
|
4457
4612
|
},
|
|
4458
4613
|
...buildCommonProviders(),
|
package/package.json
CHANGED