@bymax-one/nest-logger 1.4.28 → 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.
- package/CHANGELOG.md +156 -1
- package/README.md +20 -14
- package/dist/observability/index.cjs +15 -2
- package/dist/observability/index.mjs +15 -2
- package/dist/server/index.cjs +891 -365
- package/dist/server/index.mjs +891 -365
- package/package.json +3 -3
package/dist/server/index.cjs
CHANGED
|
@@ -25,6 +25,23 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
25
25
|
};
|
|
26
26
|
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
27
27
|
|
|
28
|
+
// src/server/config/options-refusal.util.ts
|
|
29
|
+
var refusals = /* @__PURE__ */ new WeakSet();
|
|
30
|
+
var UNREADABLE = "[BymaxLoggerModule] options could not be read";
|
|
31
|
+
function refuse(message) {
|
|
32
|
+
const error = new Error(message);
|
|
33
|
+
refusals.add(error);
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
function guardOptions(read) {
|
|
37
|
+
try {
|
|
38
|
+
return read();
|
|
39
|
+
} catch (error) {
|
|
40
|
+
if (typeof error === "object" && error !== null && refusals.delete(error)) throw error;
|
|
41
|
+
throw new Error(UNREADABLE, { cause: error });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
28
45
|
// src/server/config/drop-unset-options.ts
|
|
29
46
|
var OPTION_KEYS = {
|
|
30
47
|
service: true,
|
|
@@ -73,21 +90,56 @@ var GROUP_KEYS = {
|
|
|
73
90
|
};
|
|
74
91
|
var GROUP_NAMES = Object.keys(GROUP_KEYS);
|
|
75
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
|
+
}
|
|
76
108
|
function readSet(source, keys) {
|
|
77
|
-
const set =
|
|
109
|
+
const set = /* @__PURE__ */ Object.create(null);
|
|
78
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
|
+
}
|
|
79
121
|
const value = Reflect.get(source, key);
|
|
122
|
+
if (planted && Object.hasOwn(planted, "value") && Object.is(value, planted.value)) continue;
|
|
80
123
|
if (value !== void 0 && value !== null) Reflect.set(set, key, value);
|
|
81
124
|
}
|
|
82
125
|
return set;
|
|
83
126
|
}
|
|
84
127
|
var LIST_OPTIONS = ["redactPaths", "errorOwnFieldNames", "destinations"];
|
|
85
128
|
var HTTP_LISTS = ["excludePaths", "secretPathSegments"];
|
|
86
|
-
|
|
129
|
+
var MAX_LIST_ENTRIES = 1e4;
|
|
130
|
+
function copyLists(holder, names, prefix) {
|
|
87
131
|
for (const name of names) {
|
|
88
132
|
const value = Reflect.get(holder, name);
|
|
89
133
|
if (!Array.isArray(value)) continue;
|
|
90
134
|
const length = Reflect.get(value, "length");
|
|
135
|
+
if (!Number.isInteger(length) || length < 0) {
|
|
136
|
+
refuse(`[BymaxLoggerModule] options.${prefix}${name} has a length that is not a count`);
|
|
137
|
+
}
|
|
138
|
+
if (length > MAX_LIST_ENTRIES) {
|
|
139
|
+
refuse(
|
|
140
|
+
`[BymaxLoggerModule] options.${prefix}${name} holds more than ${String(MAX_LIST_ENTRIES)} entries`
|
|
141
|
+
);
|
|
142
|
+
}
|
|
91
143
|
Reflect.set(
|
|
92
144
|
holder,
|
|
93
145
|
name,
|
|
@@ -104,32 +156,16 @@ function dropUnsetOptions(options) {
|
|
|
104
156
|
Reflect.set(set, group, readSet(value, Object.keys(Reflect.get(GROUP_KEYS, group))));
|
|
105
157
|
}
|
|
106
158
|
const service = Reflect.get(set, "service");
|
|
107
|
-
if (isRecord(service))
|
|
159
|
+
if (isRecord(service))
|
|
160
|
+
Reflect.set(set, "service", Object.assign(/* @__PURE__ */ Object.create(null), service));
|
|
108
161
|
const serializers = Reflect.get(set, "serializers");
|
|
109
162
|
if (isRecord(serializers)) Reflect.set(set, "serializers", { ...serializers });
|
|
110
|
-
copyLists(set, LIST_OPTIONS);
|
|
163
|
+
copyLists(set, LIST_OPTIONS, "");
|
|
111
164
|
const http = Reflect.get(set, "http");
|
|
112
|
-
if (isRecord(http)) copyLists(http, HTTP_LISTS);
|
|
165
|
+
if (isRecord(http)) copyLists(http, HTTP_LISTS, "http.");
|
|
113
166
|
return set;
|
|
114
167
|
}
|
|
115
168
|
|
|
116
|
-
// src/server/config/options-refusal.util.ts
|
|
117
|
-
var refusals = /* @__PURE__ */ new WeakSet();
|
|
118
|
-
var UNREADABLE = "[BymaxLoggerModule] options could not be read";
|
|
119
|
-
function refuse(message) {
|
|
120
|
-
const error = new Error(message);
|
|
121
|
-
refusals.add(error);
|
|
122
|
-
throw error;
|
|
123
|
-
}
|
|
124
|
-
function guardOptions(read) {
|
|
125
|
-
try {
|
|
126
|
-
return read();
|
|
127
|
-
} catch (error) {
|
|
128
|
-
if (typeof error === "object" && error !== null && refusals.delete(error)) throw error;
|
|
129
|
-
throw new Error(UNREADABLE, { cause: error });
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
169
|
// src/server/constants/lifecycle-timeouts.constants.ts
|
|
134
170
|
var DEFAULT_HOOK_TIMEOUT_MS = 1e4;
|
|
135
171
|
var DEFAULT_SHUTDOWN_TIMEOUT_MS = 1e4;
|
|
@@ -186,7 +222,9 @@ function applyDefaults(given) {
|
|
|
186
222
|
options.otel
|
|
187
223
|
);
|
|
188
224
|
const merged = {
|
|
189
|
-
service: Object.freeze(
|
|
225
|
+
service: Object.freeze(
|
|
226
|
+
Object.assign(/* @__PURE__ */ Object.create(null), options.service)
|
|
227
|
+
),
|
|
190
228
|
level: options.level ?? (isProduction ? "info" : "debug"),
|
|
191
229
|
isGlobal: options.isGlobal ?? true,
|
|
192
230
|
shouldUseAsNestLogger: options.shouldUseAsNestLogger ?? true,
|
|
@@ -292,6 +330,7 @@ function checkGroup(path, value) {
|
|
|
292
330
|
if (!isRecord2(value)) reject(path, "must be an object", value);
|
|
293
331
|
return value;
|
|
294
332
|
}
|
|
333
|
+
var MAX_REDACT_PATH_LENGTH = 256;
|
|
295
334
|
var MAX_TIMER_MS = 2147483647;
|
|
296
335
|
function checkTimerMs(path, value) {
|
|
297
336
|
if (value === void 0) return;
|
|
@@ -406,6 +445,13 @@ function validateCustomization(options) {
|
|
|
406
445
|
if (!isNonEmptyString(entry)) {
|
|
407
446
|
reject(`redactPaths[${String(index)}]`, "must be a non-empty string", entry, true);
|
|
408
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
|
+
}
|
|
409
455
|
});
|
|
410
456
|
}
|
|
411
457
|
const serializers = options.serializers;
|
|
@@ -522,8 +568,131 @@ function validateOptions(given) {
|
|
|
522
568
|
validateOtel(options);
|
|
523
569
|
}
|
|
524
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
|
+
|
|
525
693
|
// src/server/config/resolve-options.ts
|
|
526
694
|
function resolveOptions(given) {
|
|
695
|
+
if (!pinoBuiltinsIntact()) throw new Error("LOGGER_BUILTINS_REPLACED");
|
|
527
696
|
return guardOptions(() => {
|
|
528
697
|
const snapshot = dropUnsetOptions(given);
|
|
529
698
|
validateOptions(snapshot);
|
|
@@ -577,7 +746,7 @@ var RESERVED_LOG_KEYS_NOT_EMITTED = Object.freeze({
|
|
|
577
746
|
});
|
|
578
747
|
|
|
579
748
|
// src/server/constants/prototype-polluting-keys.constants.ts
|
|
580
|
-
var PROTOTYPE_POLLUTING_KEYS =
|
|
749
|
+
var PROTOTYPE_POLLUTING_KEYS = capturedSet([
|
|
581
750
|
"__proto__",
|
|
582
751
|
"constructor",
|
|
583
752
|
"prototype"
|
|
@@ -629,70 +798,195 @@ function createEntryTextFinisher(redact, limit, onCut) {
|
|
|
629
798
|
};
|
|
630
799
|
}
|
|
631
800
|
|
|
632
|
-
// src/server/utils/
|
|
633
|
-
var
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
function toSingleLineMessage(text) {
|
|
640
|
-
return text.replace(
|
|
641
|
-
UNSAFE_IN_SINGLE_LINE,
|
|
642
|
-
(char) => LINE_TERMINATORS.has(char) ? "\\n" : toEscapeSequence(char)
|
|
643
|
-
);
|
|
644
|
-
}
|
|
645
|
-
function toBoundedMessage(text) {
|
|
646
|
-
return cutText(toSingleLineMessage(text));
|
|
647
|
-
}
|
|
648
|
-
function escapeControlCharacters(text) {
|
|
649
|
-
return text.replace(UNSAFE_IN_MULTILINE, toEscapeSequence);
|
|
650
|
-
}
|
|
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
|
+
];
|
|
651
808
|
|
|
652
809
|
// src/server/utils/fold-key.util.ts
|
|
653
|
-
var
|
|
654
|
-
var
|
|
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);
|
|
655
827
|
var PLAIN = /^[\x21-\x7e]*$/;
|
|
828
|
+
var NON_ASCII = /[^\x20-\x7e]/;
|
|
829
|
+
var dropNotAscii = replacer(/[^A-Za-z0-9]/g);
|
|
656
830
|
var LOOKALIKES = new Map(
|
|
657
831
|
Object.entries({
|
|
658
832
|
a: "\u0430\u03B1\u1D00",
|
|
659
833
|
b: "\u0299",
|
|
660
|
-
c: "\u0441\u03F2\u1D04",
|
|
834
|
+
c: "\u0441\u03F2\u1D04\u023C\u0188",
|
|
661
835
|
d: "\u0501\u1D05",
|
|
662
|
-
e: "\u0435\u03B5\u03F5\u1D07",
|
|
836
|
+
e: "\u0435\u03B5\u03F5\u1D07\u025B\u04BD",
|
|
663
837
|
f: "\uA730",
|
|
664
838
|
g: "\u0262",
|
|
665
839
|
h: "\u029C",
|
|
666
|
-
i: "\u0456\u03B9\u0131\u026A",
|
|
667
840
|
j: "\u0458\u1D0A",
|
|
668
841
|
k: "\u1D0B",
|
|
669
842
|
l: "\u029F",
|
|
670
843
|
m: "\u1D0D",
|
|
671
844
|
n: "\u0274",
|
|
672
|
-
o: "\u043E\u03BF\u1D0F",
|
|
673
|
-
p: "\u0440\u03C1\u1D18",
|
|
845
|
+
o: "\u043E\u03BF\u1D0F\xF8",
|
|
846
|
+
p: "\u0440\u03C1\u1D18\u01BF",
|
|
674
847
|
q: "\u051B",
|
|
675
848
|
r: "\u0280",
|
|
676
849
|
s: "\u0455\uA731",
|
|
677
|
-
t: "\u1D1B",
|
|
850
|
+
t: "\u1D1B\u0167",
|
|
678
851
|
u: "\u1D1C",
|
|
679
|
-
v: "\
|
|
852
|
+
v: "\u1D20",
|
|
680
853
|
w: "\u051D\u1D21",
|
|
681
854
|
x: "\u0445",
|
|
682
|
-
y: "\u0443\u028F",
|
|
855
|
+
y: "\u0443\u028F\u04AF",
|
|
683
856
|
z: "\u1D22"
|
|
684
857
|
}).flatMap(([latin, letters]) => [...letters].map((letter) => [letter, latin]))
|
|
685
858
|
);
|
|
859
|
+
var LOOKALIKE_PAIRS = Array.from(LOOKALIKES);
|
|
860
|
+
var I_LIKE = new Map(
|
|
861
|
+
[..."\u0456\u03B9\u0131\u026A\u0269"].map((letter) => [letter, "i"])
|
|
862
|
+
);
|
|
863
|
+
var I_LIKE_PAIRS = Array.from(I_LIKE);
|
|
686
864
|
function foldKey(key, keepSeparators = false) {
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
865
|
+
if (keepSeparators) {
|
|
866
|
+
if (matchesPattern(PLAIN, key)) return lowerCase(key);
|
|
867
|
+
return withLookalikes(
|
|
868
|
+
dropInvisible(readDots(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), "."), ""),
|
|
869
|
+
true
|
|
870
|
+
);
|
|
871
|
+
}
|
|
872
|
+
if (matchesPattern(PLAIN, key)) return lowerCase(dropNotAscii(key, ""));
|
|
873
|
+
return withLookalikes(dropNotName(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), ""), true);
|
|
874
|
+
}
|
|
875
|
+
function foldStrict(key) {
|
|
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
|
+
);
|
|
884
|
+
}
|
|
885
|
+
function withLookalikes(folded, all) {
|
|
886
|
+
let read = folded;
|
|
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
|
+
}
|
|
897
|
+
return read;
|
|
898
|
+
}
|
|
899
|
+
var ALNUM = /^[A-Za-z0-9]*$/;
|
|
900
|
+
function formOf(key) {
|
|
901
|
+
return matchesPattern(ALNUM, key) ? lowerCase(key) : foldStrict(key);
|
|
902
|
+
}
|
|
903
|
+
var answers = /* @__PURE__ */ new WeakMap();
|
|
904
|
+
function foldName(key) {
|
|
905
|
+
return formOf(key);
|
|
906
|
+
}
|
|
907
|
+
function foldedNames(names) {
|
|
908
|
+
return capturedSet(
|
|
909
|
+
Array.from(names, (name) => replaceAllText(foldName(name), SYMBOL_STAND_IN, "")).filter(
|
|
910
|
+
(name) => name !== ""
|
|
911
|
+
)
|
|
912
|
+
);
|
|
913
|
+
}
|
|
914
|
+
var MAX_CANDIDATES = 64;
|
|
915
|
+
var grouped = /* @__PURE__ */ new WeakMap();
|
|
916
|
+
function groupsOf(names) {
|
|
917
|
+
let groups = grouped.get(names);
|
|
918
|
+
if (groups === void 0) {
|
|
919
|
+
const built = /* @__PURE__ */ new Map();
|
|
920
|
+
let longest = 0;
|
|
921
|
+
for (const name of names) {
|
|
922
|
+
const size = [...name].length;
|
|
923
|
+
const same = built.get(size);
|
|
924
|
+
if (same === void 0) built.set(size, [name]);
|
|
925
|
+
else same.push(name);
|
|
926
|
+
longest = Math.max(longest, size);
|
|
927
|
+
}
|
|
928
|
+
groups = { byLength: built, longest };
|
|
929
|
+
grouped.set(names, groups);
|
|
930
|
+
}
|
|
931
|
+
return groups;
|
|
932
|
+
}
|
|
933
|
+
function matchesFolded(names, folded) {
|
|
934
|
+
if (names.has(folded)) return true;
|
|
935
|
+
if (!matchesPattern(NON_ASCII, folded)) return false;
|
|
936
|
+
const letters = [...folded];
|
|
937
|
+
const wide = letters.filter((letter) => !isAscii(letter)).length;
|
|
938
|
+
const stands = letters.filter((letter) => letter === SYMBOL_STAND_IN).length;
|
|
939
|
+
const { byLength, longest } = groupsOf(names);
|
|
940
|
+
if (longest === 0) return false;
|
|
941
|
+
if (stands > longest) return true;
|
|
942
|
+
if (letters.length - stands > longest) return false;
|
|
943
|
+
const lengths = Array.from(
|
|
944
|
+
{ length: wide + stands + 1 },
|
|
945
|
+
(_, extra) => byLength.get(letters.length - stands + extra) ?? []
|
|
946
|
+
);
|
|
947
|
+
if (lengths.reduce((count, same) => count + same.length, 0) > MAX_CANDIDATES) return true;
|
|
948
|
+
return lengths.some((same) => same.some((name) => matchesName(letters, [...name])));
|
|
949
|
+
}
|
|
950
|
+
var isAscii = (letter) => letter < "\x80";
|
|
951
|
+
function matchesName(letters, name) {
|
|
952
|
+
const initial = /* @__PURE__ */ new Set();
|
|
953
|
+
setAdd(initial, 0);
|
|
954
|
+
let at = initial;
|
|
955
|
+
for (const letter of letters) {
|
|
956
|
+
const next = /* @__PURE__ */ new Set();
|
|
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
|
+
}
|
|
964
|
+
if (isAscii(letter)) {
|
|
965
|
+
if (name[position] === letter) setAdd(next, position + 1);
|
|
966
|
+
continue;
|
|
967
|
+
}
|
|
968
|
+
setAdd(next, position + 1);
|
|
969
|
+
setAdd(next, position + 2);
|
|
970
|
+
}
|
|
971
|
+
at = next;
|
|
972
|
+
}
|
|
973
|
+
return setHas(at, name.length);
|
|
974
|
+
}
|
|
975
|
+
function matchesKey(names, key) {
|
|
976
|
+
const seen = answers.get(names) ?? /* @__PURE__ */ new Map();
|
|
977
|
+
answers.set(names, seen);
|
|
978
|
+
const known = seen.get(key);
|
|
979
|
+
if (known !== void 0) return known;
|
|
980
|
+
const folded = formOf(key);
|
|
981
|
+
const answer = names.has(folded) || matchesFolded(names, folded);
|
|
982
|
+
if (key.length <= 64) {
|
|
983
|
+
if (seen.size > 1023) seen.clear();
|
|
984
|
+
seen.set(key, answer);
|
|
985
|
+
}
|
|
986
|
+
return answer;
|
|
692
987
|
}
|
|
693
988
|
|
|
694
989
|
// src/server/utils/hide-message-in-stack.util.ts
|
|
695
|
-
var FRAME_LINE = /\n[ \t]+at /g;
|
|
696
990
|
function failureTable(message) {
|
|
697
991
|
const table = new Int32Array(message.length);
|
|
698
992
|
for (let i = 1, matched = 0; i < message.length; i += 1) {
|
|
@@ -703,6 +997,7 @@ function failureTable(message) {
|
|
|
703
997
|
return table;
|
|
704
998
|
}
|
|
705
999
|
function occurrences(stack, message) {
|
|
1000
|
+
if (message.length > stack.length) return [];
|
|
706
1001
|
const table = failureTable(message);
|
|
707
1002
|
const spans = [];
|
|
708
1003
|
for (let i = 0, matched = 0; i < stack.length; i += 1) {
|
|
@@ -717,37 +1012,23 @@ function occurrences(stack, message) {
|
|
|
717
1012
|
}
|
|
718
1013
|
return spans;
|
|
719
1014
|
}
|
|
720
|
-
function
|
|
721
|
-
|
|
722
|
-
for (const line of stack.matchAll(FRAME_LINE)) {
|
|
723
|
-
while (next < spans.length && spans[next][1] <= line.index) next += 1;
|
|
724
|
-
const span = spans[next];
|
|
725
|
-
if (span === void 0 || line.index < span[0]) return line.index;
|
|
726
|
-
}
|
|
727
|
-
return stack.length;
|
|
728
|
-
}
|
|
729
|
-
function hideMessageInStack(stack, message, replacement) {
|
|
730
|
-
if (message === "") return stack;
|
|
731
|
-
if (message.length > stack.length) return stack;
|
|
732
|
-
const spans = occurrences(stack, message);
|
|
733
|
-
const end = headerEnd(stack, spans);
|
|
1015
|
+
function hideMessagesInStack(stack, messages, replacement, limit) {
|
|
1016
|
+
const spans = messages.filter((message) => message !== "").flatMap((message) => occurrences(stack, message)).sort((a, b) => a[0] - b[0]);
|
|
734
1017
|
let result = "";
|
|
735
1018
|
let from = 0;
|
|
736
|
-
|
|
1019
|
+
let end = limit;
|
|
1020
|
+
for (const [start, stop] of spans) {
|
|
1021
|
+
if (start >= end) break;
|
|
1022
|
+
if (start < from) {
|
|
1023
|
+
from = Math.max(from, stop);
|
|
1024
|
+
end = Math.max(end, from);
|
|
1025
|
+
continue;
|
|
1026
|
+
}
|
|
737
1027
|
result += stack.slice(from, start) + replacement;
|
|
738
1028
|
from = stop;
|
|
1029
|
+
end = Math.max(end, stop);
|
|
739
1030
|
}
|
|
740
|
-
return result + stack.slice(from);
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
// src/server/utils/is-plain-record.util.ts
|
|
744
|
-
function isPlainRecord(node) {
|
|
745
|
-
try {
|
|
746
|
-
const prototype = Object.getPrototypeOf(node);
|
|
747
|
-
return prototype === Object.prototype || prototype === null;
|
|
748
|
-
} catch {
|
|
749
|
-
return false;
|
|
750
|
-
}
|
|
1031
|
+
return result + stack.slice(from, Math.max(end, from));
|
|
751
1032
|
}
|
|
752
1033
|
|
|
753
1034
|
// src/server/utils/censor-stack-header.util.ts
|
|
@@ -756,17 +1037,37 @@ function endsHeader(stack, message, from) {
|
|
|
756
1037
|
const end = from + message.length;
|
|
757
1038
|
return stack.startsWith(message, from) && (end === stack.length || stack.startsWith("\n", end));
|
|
758
1039
|
}
|
|
759
|
-
function
|
|
760
|
-
if (message === "" || censored === message) return stack;
|
|
1040
|
+
function splitCensoredHeader(stack, name, message, censored) {
|
|
1041
|
+
if (message === "" || censored === message) return ["", stack];
|
|
761
1042
|
const separator = stack.indexOf(NAME_SEPARATOR);
|
|
762
1043
|
if (separator !== -1 && stack.lastIndexOf("\n", separator) === -1) {
|
|
763
1044
|
const from = separator + NAME_SEPARATOR.length;
|
|
764
1045
|
if (endsHeader(stack, message, from)) {
|
|
765
|
-
return stack.slice(0, from) + censored
|
|
1046
|
+
return [stack.slice(0, from) + censored, stack.slice(from + message.length)];
|
|
766
1047
|
}
|
|
767
1048
|
}
|
|
768
|
-
if (endsHeader(stack, message, 0)) return censored
|
|
769
|
-
return name === "" ? censored : name + NAME_SEPARATOR + censored;
|
|
1049
|
+
if (endsHeader(stack, message, 0)) return [censored, stack.slice(message.length)];
|
|
1050
|
+
return [name === "" ? censored : name + NAME_SEPARATOR + censored, ""];
|
|
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);
|
|
770
1071
|
}
|
|
771
1072
|
function isError(value) {
|
|
772
1073
|
try {
|
|
@@ -791,17 +1092,17 @@ var DEFAULT_SAFE_ERROR_FIELDS = [
|
|
|
791
1092
|
"schema",
|
|
792
1093
|
"routine"
|
|
793
1094
|
];
|
|
794
|
-
var DERIVED_ERROR_FIELDS =
|
|
1095
|
+
var DERIVED_ERROR_FIELDS = capturedSet([
|
|
795
1096
|
"name",
|
|
796
1097
|
"message",
|
|
797
1098
|
"stack",
|
|
798
1099
|
"cause",
|
|
799
1100
|
"errors"
|
|
800
1101
|
]);
|
|
801
|
-
var ALL_OWN_FIELDS = { safe: false, names:
|
|
1102
|
+
var ALL_OWN_FIELDS = { safe: false, names: capturedSet() };
|
|
802
1103
|
function createOwnFieldPolicy(mode, extraNames) {
|
|
803
1104
|
if (mode === "all") return ALL_OWN_FIELDS;
|
|
804
|
-
return { safe: true, names:
|
|
1105
|
+
return { safe: true, names: capturedSet([...DEFAULT_SAFE_ERROR_FIELDS, ...extraNames]) };
|
|
805
1106
|
}
|
|
806
1107
|
function allowsOwnField(policy, key) {
|
|
807
1108
|
return !policy.safe || DERIVED_ERROR_FIELDS.has(key) || key === "_errorFieldsIncomplete" || policy.names.has(key);
|
|
@@ -855,12 +1156,12 @@ function readScrubbedStack(value, name, message, textName, result, walk2) {
|
|
|
855
1156
|
const header = headerCensor(name, message, walk2.censorMessage);
|
|
856
1157
|
return textName ? scrubStack(stack, header) : scrubStack(withNamedHeader(stack, message), header, stack.length > MAX_STACK_SCAN);
|
|
857
1158
|
}
|
|
858
|
-
var
|
|
1159
|
+
var FRAME_LINE = /\n[ \t]+at /;
|
|
859
1160
|
function withNamedHeader(stack, message) {
|
|
860
1161
|
const head = stack.slice(0, MAX_STACK_SCAN);
|
|
861
1162
|
const found = message === "" ? -1 : head.indexOf(message);
|
|
862
1163
|
if (found !== -1) return `Error: ${head.slice(found)}`;
|
|
863
|
-
const end = head.search(
|
|
1164
|
+
const end = head.search(FRAME_LINE);
|
|
864
1165
|
const frames = end === -1 ? "" : head.slice(end);
|
|
865
1166
|
return `Error${message === "" ? "" : `: ${message}`}${frames}`;
|
|
866
1167
|
}
|
|
@@ -898,26 +1199,30 @@ function toSanitizedError(value, seen, depth2, walk2) {
|
|
|
898
1199
|
return { name: "SanitizeFailed", message: "Failed to sanitize the thrown value" };
|
|
899
1200
|
}
|
|
900
1201
|
}
|
|
901
|
-
var ARGUMENT_FIELDS =
|
|
902
|
-
var DATABASE_VALUE_FIELDS =
|
|
1202
|
+
var ARGUMENT_FIELDS = capturedSet(["args", "parameters"]);
|
|
1203
|
+
var DATABASE_VALUE_FIELDS = capturedSet(["detail", "where", "internalQuery"]);
|
|
903
1204
|
var SQLSTATE = /^[0-9A-DF-Z][0-9A-Z]{4}$/;
|
|
904
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
|
+
}
|
|
905
1210
|
function isDatabaseError(source) {
|
|
906
|
-
const code =
|
|
907
|
-
return typeof code === "string" && SQLSTATE
|
|
1211
|
+
const code = ownDataValue(source, "code");
|
|
1212
|
+
return typeof code === "string" && matchesPattern(SQLSTATE, code);
|
|
908
1213
|
}
|
|
909
1214
|
function ownFieldForLog(source, key, value, policy = ALL_OWN_FIELDS) {
|
|
910
1215
|
if (!allowsOwnField(policy, key)) return OMIT_OWN_FIELD;
|
|
911
|
-
if (ARGUMENT_FIELDS.has(key
|
|
1216
|
+
if (ARGUMENT_FIELDS.has(lowerCase(key))) return OMIT_OWN_FIELD;
|
|
912
1217
|
if (DATABASE_VALUE_FIELDS.has(key) && isDatabaseError(source)) return OMIT_OWN_FIELD;
|
|
913
1218
|
if (key !== "command" || typeof value !== "object" || value === null) {
|
|
914
1219
|
return withBinaryAsSize(value);
|
|
915
1220
|
}
|
|
916
|
-
const name =
|
|
1221
|
+
const name = ownDataValue(value, "name");
|
|
917
1222
|
return typeof name === "string" ? { name } : OMIT_OWN_FIELD;
|
|
918
1223
|
}
|
|
919
1224
|
function defineErrorField(target, key, value) {
|
|
920
|
-
Object.defineProperty(target, key, { value, enumerable: true });
|
|
1225
|
+
Object.defineProperty(target, key, bareDescriptor({ value, enumerable: true }));
|
|
921
1226
|
}
|
|
922
1227
|
function assignOwnErrorFields(target, source, policy = ALL_OWN_FIELDS) {
|
|
923
1228
|
try {
|
|
@@ -934,7 +1239,11 @@ function assignOwnErrorFields(target, source, policy = ALL_OWN_FIELDS) {
|
|
|
934
1239
|
}
|
|
935
1240
|
}
|
|
936
1241
|
function markIncomplete(target) {
|
|
937
|
-
Reflect.defineProperty(
|
|
1242
|
+
Reflect.defineProperty(
|
|
1243
|
+
target,
|
|
1244
|
+
"_errorFieldsIncomplete",
|
|
1245
|
+
bareDescriptor({ value: true, enumerable: true })
|
|
1246
|
+
);
|
|
938
1247
|
}
|
|
939
1248
|
function readOptional(read, node) {
|
|
940
1249
|
try {
|
|
@@ -969,7 +1278,7 @@ var MAX_PLAIN_NAME = 64;
|
|
|
969
1278
|
var PLAIN_NAME = /^[A-Za-z_$][\w$.-]*$/;
|
|
970
1279
|
function censorName(name, censorMessage) {
|
|
971
1280
|
if (censorMessage === void 0 || name === "") return name;
|
|
972
|
-
if (name.length <= MAX_PLAIN_NAME && PLAIN_NAME
|
|
1281
|
+
if (name.length <= MAX_PLAIN_NAME && matchesPattern(PLAIN_NAME, name)) return name;
|
|
973
1282
|
try {
|
|
974
1283
|
return censorMessage(name);
|
|
975
1284
|
} catch {
|
|
@@ -989,15 +1298,24 @@ function headerCensor(name, message, censorMessage) {
|
|
|
989
1298
|
function censorStackName(stack, header) {
|
|
990
1299
|
return header.name !== "" && stack.startsWith(header.name) ? header.censoredName + stack.slice(header.name.length) : stack;
|
|
991
1300
|
}
|
|
1301
|
+
function censorMessageInStack(stack, header) {
|
|
1302
|
+
const [opened, rest] = splitCensoredHeader(
|
|
1303
|
+
censorStackName(stack, header),
|
|
1304
|
+
header.censoredName,
|
|
1305
|
+
header.message,
|
|
1306
|
+
header.censored
|
|
1307
|
+
);
|
|
1308
|
+
return header.censored === header.message ? opened + rest : opened + hideMessagesInStack(
|
|
1309
|
+
rest,
|
|
1310
|
+
[header.message],
|
|
1311
|
+
header.censored,
|
|
1312
|
+
Math.max(0, MAX_STACK_SCAN - (stack.length - rest.length))
|
|
1313
|
+
);
|
|
1314
|
+
}
|
|
992
1315
|
function scrubStack(stack, header, wasLonger = false) {
|
|
993
|
-
const
|
|
1316
|
+
const window = stack.slice(0, MAX_STACK_SCAN + (header?.message.length ?? 0));
|
|
994
1317
|
const scrubbed = escapeControlCharacters(
|
|
995
|
-
(header === void 0 ?
|
|
996
|
-
censorStackName(head, header),
|
|
997
|
-
header.censoredName,
|
|
998
|
-
header.message,
|
|
999
|
-
header.censored
|
|
1000
|
-
)).split("\n").filter((line) => !line.includes("node_modules")).join("\n")
|
|
1318
|
+
(header === void 0 ? window : censorMessageInStack(window, header)).slice(0, MAX_STACK_SCAN).split("\n").filter((line) => !line.includes("node_modules")).join("\n")
|
|
1001
1319
|
);
|
|
1002
1320
|
return cutText(scrubbed, wasLonger || stack.length > MAX_STACK_SCAN);
|
|
1003
1321
|
}
|
|
@@ -1011,6 +1329,178 @@ function createWidthMarker(omitted) {
|
|
|
1011
1329
|
return { _truncated: true, _reason: "aggregate-width-exceeded", _omitted: omitted };
|
|
1012
1330
|
}
|
|
1013
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
|
+
|
|
1014
1504
|
// src/server/services/pino-logger.service.ts
|
|
1015
1505
|
var OWNED_PAYLOAD_KEYS = ["logKey", "userId", "context"];
|
|
1016
1506
|
var ENTRY_STRUCTURE_KEYS = ["level", "time", "msg", "service", "deployment"];
|
|
@@ -1021,17 +1511,17 @@ var RESOURCE_KEYS = [
|
|
|
1021
1511
|
"service.instance.id",
|
|
1022
1512
|
"deployment.environment.name"
|
|
1023
1513
|
];
|
|
1024
|
-
var OWNED_KEY_SPELLINGS =
|
|
1514
|
+
var OWNED_KEY_SPELLINGS = capturedSet(
|
|
1025
1515
|
[...OWNED_PAYLOAD_KEYS, ...ENTRY_STRUCTURE_KEYS, ...RESOURCE_KEYS].map((key) => foldKey(key))
|
|
1026
1516
|
);
|
|
1027
|
-
var DERIVED_KEYS =
|
|
1517
|
+
var DERIVED_KEYS = capturedSet([
|
|
1028
1518
|
"exception.type",
|
|
1029
1519
|
"exception.message",
|
|
1030
1520
|
"exception.stacktrace",
|
|
1031
1521
|
"error.type"
|
|
1032
1522
|
]);
|
|
1033
1523
|
var isOwnedKey = (key) => {
|
|
1034
|
-
const lower = key
|
|
1524
|
+
const lower = lowerCase(key);
|
|
1035
1525
|
return OWNED_KEY_SPELLINGS.has(foldKey(key)) || DERIVED_KEYS.has(foldKey(key, true)) || lower.startsWith("service.") || lower.startsWith("deployment.");
|
|
1036
1526
|
};
|
|
1037
1527
|
function withoutOwnedKeys(metadata, omit) {
|
|
@@ -1070,12 +1560,27 @@ function objectMessageText(fields) {
|
|
|
1070
1560
|
}
|
|
1071
1561
|
return void 0;
|
|
1072
1562
|
}
|
|
1073
|
-
function hideStackMessage(payload, text, censor) {
|
|
1074
|
-
const
|
|
1075
|
-
if (text?.key !== "message"
|
|
1563
|
+
function hideStackMessage(payload, text, censor, positional) {
|
|
1564
|
+
const kept = positional === void 0 ? void 0 : cutText(positional);
|
|
1565
|
+
if (text?.key !== "message") return kept;
|
|
1076
1566
|
const censored = censor(text.text);
|
|
1077
|
-
if (censored === text.text) return;
|
|
1078
|
-
|
|
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);
|
|
1079
1584
|
}
|
|
1080
1585
|
function readObjectMessage(message) {
|
|
1081
1586
|
const fields = isPlainRecord(message) && !isErrorLike(message) ? message : void 0;
|
|
@@ -1096,9 +1601,12 @@ function findErrorParam(optionalParams) {
|
|
|
1096
1601
|
}
|
|
1097
1602
|
function assignIfDefined(payload, key, value) {
|
|
1098
1603
|
if (value !== void 0) {
|
|
1099
|
-
Reflect.defineProperty(payload, key, { value, enumerable: true });
|
|
1604
|
+
Reflect.defineProperty(payload, key, bareDescriptor({ value, enumerable: true }));
|
|
1100
1605
|
}
|
|
1101
1606
|
}
|
|
1607
|
+
function emitRecord(pino2, level, payload, msg) {
|
|
1608
|
+
if (pinoBuiltinsIntact()) pino2[level](payload, msg);
|
|
1609
|
+
}
|
|
1102
1610
|
exports.PinoLoggerService = class PinoLoggerService {
|
|
1103
1611
|
/**
|
|
1104
1612
|
* **A hand-built instance is NOT this library's behaviour.** Constructing
|
|
@@ -1153,17 +1661,27 @@ exports.PinoLoggerService = class PinoLoggerService {
|
|
|
1153
1661
|
if (isErrorLike(message)) {
|
|
1154
1662
|
const payload2 = { err: message };
|
|
1155
1663
|
assignIfDefined(payload2, "context", this.resolveContext(optionalParams));
|
|
1156
|
-
this.pino
|
|
1664
|
+
emitRecord(this.pino, "error", payload2, this.errorText(message));
|
|
1157
1665
|
return;
|
|
1158
1666
|
}
|
|
1159
1667
|
const stack = typeof optionalParams[0] === "string" ? optionalParams[0] : void 0;
|
|
1160
1668
|
const context = typeof optionalParams[1] === "string" ? optionalParams[1] : this.context;
|
|
1161
1669
|
const { fields, text, payload } = readObjectMessage(message);
|
|
1162
|
-
|
|
1670
|
+
const positional = hideStackMessage(
|
|
1671
|
+
payload,
|
|
1672
|
+
text,
|
|
1673
|
+
(message2) => this.censorText({ key: "message", text: message2 }),
|
|
1674
|
+
stack
|
|
1675
|
+
);
|
|
1163
1676
|
assignIfDefined(payload, "context", context);
|
|
1164
|
-
assignIfDefined(payload, "stack",
|
|
1677
|
+
assignIfDefined(payload, "stack", positional);
|
|
1165
1678
|
assignIfDefined(payload, "err", findErrorParam(optionalParams));
|
|
1166
|
-
|
|
1679
|
+
emitRecord(
|
|
1680
|
+
this.pino,
|
|
1681
|
+
"error",
|
|
1682
|
+
payload,
|
|
1683
|
+
this.nestStyleMessage("error", void 0, fields, text, message)
|
|
1684
|
+
);
|
|
1167
1685
|
}
|
|
1168
1686
|
/**
|
|
1169
1687
|
* NestJS `warn` (warn level).
|
|
@@ -1249,7 +1767,7 @@ exports.PinoLoggerService = class PinoLoggerService {
|
|
|
1249
1767
|
};
|
|
1250
1768
|
assignIfDefined(payload, "userId", userId);
|
|
1251
1769
|
assignIfDefined(payload, "context", this.context);
|
|
1252
|
-
this.pino
|
|
1770
|
+
emitRecord(this.pino, "error", payload, this.errorText(error));
|
|
1253
1771
|
}
|
|
1254
1772
|
// ─── Helpers / escape hatches ─────────────────────────────────────────────
|
|
1255
1773
|
/**
|
|
@@ -1309,9 +1827,9 @@ exports.PinoLoggerService = class PinoLoggerService {
|
|
|
1309
1827
|
assignIfDefined(payload, "context", this.context);
|
|
1310
1828
|
const line = toBoundedMessage(message);
|
|
1311
1829
|
if (level === "info") {
|
|
1312
|
-
this.pino
|
|
1830
|
+
emitRecord(this.pino, "info", payload, line);
|
|
1313
1831
|
} else {
|
|
1314
|
-
this.pino
|
|
1832
|
+
emitRecord(this.pino, "warn", payload, line);
|
|
1315
1833
|
}
|
|
1316
1834
|
}
|
|
1317
1835
|
/** Emit a NestJS-style variadic log, dispatching by level without computed indexing. */
|
|
@@ -1367,23 +1885,7 @@ exports.PinoLoggerService = class PinoLoggerService {
|
|
|
1367
1885
|
const leading = isErrorLike(message) ? message : void 0;
|
|
1368
1886
|
assignIfDefined(payload, "err", leading ?? findErrorParam(optionalParams));
|
|
1369
1887
|
const msg = this.nestStyleMessage(level, leading, fields, text, message);
|
|
1370
|
-
|
|
1371
|
-
case "info":
|
|
1372
|
-
this.pino.info(payload, msg);
|
|
1373
|
-
break;
|
|
1374
|
-
case "warn":
|
|
1375
|
-
this.pino.warn(payload, msg);
|
|
1376
|
-
break;
|
|
1377
|
-
case "debug":
|
|
1378
|
-
this.pino.debug(payload, msg);
|
|
1379
|
-
break;
|
|
1380
|
-
case "trace":
|
|
1381
|
-
this.pino.trace(payload, msg);
|
|
1382
|
-
break;
|
|
1383
|
-
case "fatal":
|
|
1384
|
-
this.pino.fatal(payload, msg);
|
|
1385
|
-
break;
|
|
1386
|
-
}
|
|
1888
|
+
emitRecord(this.pino, level, payload, msg);
|
|
1387
1889
|
}
|
|
1388
1890
|
};
|
|
1389
1891
|
exports.PinoLoggerService = __decorateClass([
|
|
@@ -1577,6 +2079,7 @@ var NANOID_REGEX = /\/[A-Za-z0-9_-]{21}(?![A-Za-z0-9_-])/g;
|
|
|
1577
2079
|
var NUMERIC_ID_REGEX = /\/\d+/g;
|
|
1578
2080
|
var ID_PLACEHOLDER = "/:id";
|
|
1579
2081
|
var SECRET_PLACEHOLDER = ":redacted";
|
|
2082
|
+
var WHOLE_PATH_PLACEHOLDER = `/${SECRET_PLACEHOLDER}`;
|
|
1580
2083
|
var HEX_SECRET_REGEX = /^[0-9a-f]{32,}$/i;
|
|
1581
2084
|
var JWT_SECRET_REGEX = /^eyJ[\w-]*\.[\w-]+\.[\w-]*$/;
|
|
1582
2085
|
var TOKEN_SECRET_REGEX = /^[A-Za-z0-9_+/-]{32,}={0,2}$/;
|
|
@@ -1608,6 +2111,7 @@ function looksLikeToken(value) {
|
|
|
1608
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);
|
|
1609
2112
|
}
|
|
1610
2113
|
function secretPathSegments(url, extra = []) {
|
|
2114
|
+
if (!pinoBuiltinsIntact()) return [url];
|
|
1611
2115
|
const found = /* @__PURE__ */ new Set();
|
|
1612
2116
|
for (const segment of stripQueryString(url).split("/")) {
|
|
1613
2117
|
if (isSecretSegment(segment, extra)) found.add(segment);
|
|
@@ -1615,6 +2119,7 @@ function secretPathSegments(url, extra = []) {
|
|
|
1615
2119
|
return [...found];
|
|
1616
2120
|
}
|
|
1617
2121
|
function scrubSecretSegments(path, extra = []) {
|
|
2122
|
+
if (!pinoBuiltinsIntact()) return WHOLE_PATH_PLACEHOLDER;
|
|
1618
2123
|
return path.split("/").map((segment) => isSecretSegment(segment, extra) ? SECRET_PLACEHOLDER : segment).join("/");
|
|
1619
2124
|
}
|
|
1620
2125
|
function normalizeUrl(url, extra = []) {
|
|
@@ -1625,6 +2130,7 @@ function stripQueryString(url) {
|
|
|
1625
2130
|
return queryStart === -1 ? url : url.slice(0, queryStart);
|
|
1626
2131
|
}
|
|
1627
2132
|
function withoutRequestSecrets(text, extra, ...urls) {
|
|
2133
|
+
if (!pinoBuiltinsIntact()) return SECRET_PLACEHOLDER;
|
|
1628
2134
|
let result = text;
|
|
1629
2135
|
const segments = /* @__PURE__ */ new Set();
|
|
1630
2136
|
for (const url of urls) {
|
|
@@ -2124,13 +2630,128 @@ exports.LogContextService = class LogContextService {
|
|
|
2124
2630
|
exports.LogContextService = __decorateClass([
|
|
2125
2631
|
common.Injectable()
|
|
2126
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
|
+
}
|
|
2127
2748
|
|
|
2128
2749
|
// src/server/middlewares/request-id.middleware.ts
|
|
2129
2750
|
var REQUEST_ID_HEADER = "x-request-id";
|
|
2130
2751
|
var MAX_CORRELATION_ID_LENGTH = 256;
|
|
2131
2752
|
var CORRELATION_ID_CHARSET = /^[A-Za-z0-9._:/+=-]+$/;
|
|
2132
2753
|
function settleLate(answer) {
|
|
2133
|
-
|
|
2754
|
+
absorb(answer);
|
|
2134
2755
|
}
|
|
2135
2756
|
var INHERITABLE_CONTEXT_KEYS = ["requestId", "tenantId"];
|
|
2136
2757
|
function isAcceptableHeaderValue(value) {
|
|
@@ -2588,7 +3209,7 @@ function createTraceContextMixin(logContext, opts) {
|
|
|
2588
3209
|
// src/server/utils/compile-redact-paths.util.ts
|
|
2589
3210
|
function compileRedactPaths(extraPaths, shouldSkipDefaults) {
|
|
2590
3211
|
const sources = shouldSkipDefaults ? [extraPaths] : [DEFAULT_REDACT_PATHS, extraPaths];
|
|
2591
|
-
return Array.from(
|
|
3212
|
+
return Array.from(capturedSet(sources.flat()));
|
|
2592
3213
|
}
|
|
2593
3214
|
|
|
2594
3215
|
// src/server/utils/cut-strings.util.ts
|
|
@@ -2736,15 +3357,14 @@ function destinationToStream(destination, health, maxQueueBytes = 0, censorMessa
|
|
|
2736
3357
|
callback();
|
|
2737
3358
|
} else {
|
|
2738
3359
|
health.markWritePending(destination);
|
|
2739
|
-
|
|
2740
|
-
() =>
|
|
3360
|
+
awaitOutcome(
|
|
3361
|
+
() => result,
|
|
3362
|
+
(outcome) => {
|
|
2741
3363
|
health.markWriteSettled(destination);
|
|
2742
|
-
callback();
|
|
3364
|
+
if (outcome.ok) callback();
|
|
3365
|
+
else onFailure(outcome.cause);
|
|
2743
3366
|
},
|
|
2744
|
-
|
|
2745
|
-
health.markWriteSettled(destination);
|
|
2746
|
-
onFailure(cause);
|
|
2747
|
-
}
|
|
3367
|
+
result
|
|
2748
3368
|
);
|
|
2749
3369
|
}
|
|
2750
3370
|
} catch (cause) {
|
|
@@ -2763,11 +3383,11 @@ function mergeMixinSafely(mergeObject, mixinObject) {
|
|
|
2763
3383
|
const merged = {};
|
|
2764
3384
|
const written = /* @__PURE__ */ new Set();
|
|
2765
3385
|
for (const [key, value] of Object.entries(mixinObject)) {
|
|
2766
|
-
if (value !== void 0) written
|
|
3386
|
+
if (value !== void 0) setAdd(written, foldKey(key));
|
|
2767
3387
|
}
|
|
2768
3388
|
for (const key of Object.keys(mergeObject)) {
|
|
2769
3389
|
if (key === PROTOTYPE_KEY) continue;
|
|
2770
|
-
if (key !== EXPLICIT_USER_KEY && written
|
|
3390
|
+
if (key !== EXPLICIT_USER_KEY && setHas(written, foldKey(key))) continue;
|
|
2771
3391
|
Reflect.set(merged, key, Reflect.get(mergeObject, key));
|
|
2772
3392
|
}
|
|
2773
3393
|
for (const [key, value] of Object.entries(mixinObject)) {
|
|
@@ -2789,206 +3409,83 @@ function mergeMixinSafely(mergeObject, mixinObject) {
|
|
|
2789
3409
|
function censorRawHeaders(raw, sensitive, censor) {
|
|
2790
3410
|
return raw.map((entry, index) => {
|
|
2791
3411
|
const name = index % 2 === 1 ? raw[index - 1] : void 0;
|
|
2792
|
-
return typeof name === "string" && sensitive
|
|
3412
|
+
return typeof name === "string" && matchesKey(sensitive, name) ? censor : entry;
|
|
2793
3413
|
});
|
|
2794
3414
|
}
|
|
2795
3415
|
|
|
2796
|
-
// src/server/utils/redact-error-parts.util.ts
|
|
2797
|
-
function defineOwn(target, key, value) {
|
|
2798
|
-
Reflect.defineProperty(target, key, { value, enumerable: true, writable: true });
|
|
2799
|
-
}
|
|
2800
|
-
var linkDepths = /* @__PURE__ */ new WeakMap();
|
|
2801
|
-
var ERROR_TEXT_FIELDS = /* @__PURE__ */ new Set(["name", "message", "stack"]);
|
|
2802
|
-
var INCOMPLETE_KEY = "_errorFieldsIncomplete";
|
|
2803
|
-
var widthMarkers = /* @__PURE__ */ new WeakSet();
|
|
2804
|
-
function capErrors(errors, host) {
|
|
2805
|
-
if (!Array.isArray(errors) || errors.length <= MAX_AGGREGATE_ERRORS) return errors;
|
|
2806
|
-
if (host.hasToJson(errors)) return errors;
|
|
2807
|
-
const kept = [];
|
|
2808
|
-
for (let index = 0; index < MAX_AGGREGATE_ERRORS; index++) kept.push(Reflect.get(errors, index));
|
|
2809
|
-
const marker = createWidthMarker(errors.length - MAX_AGGREGATE_ERRORS);
|
|
2810
|
-
widthMarkers.add(marker);
|
|
2811
|
-
kept.push(marker);
|
|
2812
|
-
return kept;
|
|
2813
|
-
}
|
|
2814
|
-
function linkTargets(value) {
|
|
2815
|
-
const targets = [];
|
|
2816
|
-
const take = (link) => {
|
|
2817
|
-
if (typeof link === "object" && link !== null) targets.push(link);
|
|
2818
|
-
};
|
|
2819
|
-
if (!Array.isArray(value)) take(value);
|
|
2820
|
-
else for (let index = 0; index < value.length; index++) take(Reflect.get(value, index));
|
|
2821
|
-
return targets;
|
|
2822
|
-
}
|
|
2823
|
-
function walkChainPart(value, level, host, depth2) {
|
|
2824
|
-
const targets = linkTargets(value);
|
|
2825
|
-
if (targets.length > 0 && level + 1 > DEFAULT_MAX_CAUSE_DEPTH) {
|
|
2826
|
-
if (Array.isArray(value) && host.nameKey === "name") {
|
|
2827
|
-
return Array.from({ length: value.length }, (_member, index) => {
|
|
2828
|
-
const member = Reflect.get(value, index);
|
|
2829
|
-
return typeof member === "object" && member !== null && widthMarkers.has(member) ? member : createDepthMarker();
|
|
2830
|
-
});
|
|
2831
|
-
}
|
|
2832
|
-
return createDepthMarker();
|
|
2833
|
-
}
|
|
2834
|
-
const before = new Map(targets.map((target) => [target, linkDepths.get(target)]));
|
|
2835
|
-
for (const target of targets) linkDepths.set(target, level + 1);
|
|
2836
|
-
try {
|
|
2837
|
-
return host.walk(value, depth2 + 1);
|
|
2838
|
-
} finally {
|
|
2839
|
-
before.forEach((earlier, target) => {
|
|
2840
|
-
if (earlier === void 0) linkDepths.delete(target);
|
|
2841
|
-
else linkDepths.set(target, earlier);
|
|
2842
|
-
});
|
|
2843
|
-
}
|
|
2844
|
-
}
|
|
2845
|
-
function cutOrWalk(value, level, host, depth2) {
|
|
2846
|
-
return typeof value === "string" ? cutText(value) : walkChainPart(value, level, host, depth2);
|
|
2847
|
-
}
|
|
2848
|
-
function writeName(value, level, host, depth2) {
|
|
2849
|
-
const censored = host.censorName(typeof value === "string" ? cutText(value) : value);
|
|
2850
|
-
return censored === value ? cutOrWalk(value, level, host, depth2) : censored;
|
|
2851
|
-
}
|
|
2852
|
-
function addErrorParts(copy, error, ownKeys, host, depth2) {
|
|
2853
|
-
const taken = new Set(ownKeys);
|
|
2854
|
-
const level = linkDepths.get(error) ?? 0;
|
|
2855
|
-
let incomplete = false;
|
|
2856
|
-
const add = (key, covers, read, write = (value) => walkChainPart(value, level, host, depth2)) => {
|
|
2857
|
-
if (taken.has(key)) return;
|
|
2858
|
-
try {
|
|
2859
|
-
const written = write(read());
|
|
2860
|
-
if (written === void 0) return;
|
|
2861
|
-
const covered = covers.some((name) => host.sensitive.has(name));
|
|
2862
|
-
defineOwn(copy, key, covered ? host.censor : written);
|
|
2863
|
-
} catch {
|
|
2864
|
-
incomplete = true;
|
|
2865
|
-
}
|
|
2866
|
-
};
|
|
2867
|
-
add(
|
|
2868
|
-
host.nameKey,
|
|
2869
|
-
[host.nameKey, "name"],
|
|
2870
|
-
() => error.name,
|
|
2871
|
-
(name) => writeName(name, level, host, depth2)
|
|
2872
|
-
);
|
|
2873
|
-
add(
|
|
2874
|
-
"message",
|
|
2875
|
-
["message"],
|
|
2876
|
-
() => error.message,
|
|
2877
|
-
(message) => cutOrWalk(message, level, host, depth2)
|
|
2878
|
-
);
|
|
2879
|
-
add(
|
|
2880
|
-
"stack",
|
|
2881
|
-
["stack", "name", "message"],
|
|
2882
|
-
() => error.stack,
|
|
2883
|
-
(stack) => typeof stack === "string" ? scrubStack(stack) : void 0
|
|
2884
|
-
);
|
|
2885
|
-
add("cause", ["cause"], () => error.cause);
|
|
2886
|
-
add("errors", ["errors"], () => capErrors(error.errors, host));
|
|
2887
|
-
if (incomplete && !taken.has(INCOMPLETE_KEY)) defineOwn(copy, INCOMPLETE_KEY, true);
|
|
2888
|
-
}
|
|
2889
|
-
|
|
2890
|
-
// src/server/utils/error-text-exemption.util.ts
|
|
2891
|
-
var ERROR_TEXT_KEYS = /* @__PURE__ */ new Set(["message"]);
|
|
2892
|
-
function leavesErrorText(rules, key, value, honorToJson) {
|
|
2893
|
-
return rules.errorTextToSerializer && !honorToJson && key === "err" && !Array.isArray(value);
|
|
2894
|
-
}
|
|
2895
|
-
function rulesBelow(rules, key, value, honorToJson) {
|
|
2896
|
-
if (leavesErrorText(rules, key, value, honorToJson)) {
|
|
2897
|
-
return { ...rules, exemptKeys: ERROR_TEXT_KEYS };
|
|
2898
|
-
}
|
|
2899
|
-
return rules.exemptKeys === void 0 && rules.headerKept !== true ? rules : { ...rules, exemptKeys: void 0, headerKept: void 0 };
|
|
2900
|
-
}
|
|
2901
|
-
function isCensored(rules, key, value) {
|
|
2902
|
-
const lower = key.toLowerCase();
|
|
2903
|
-
return rules.sensitive.has(lower) && !(typeof value === "string" && rules.exemptKeys?.has(lower));
|
|
2904
|
-
}
|
|
2905
|
-
function messageCensor(rules) {
|
|
2906
|
-
return (text) => rules.sensitive.has("message") ? rules.censor : text;
|
|
2907
|
-
}
|
|
2908
|
-
function headerMessage(rules, source, keys, isError2) {
|
|
2909
|
-
if (isError2 || !rules.sensitive.has("message") || rules.exemptKeys?.has("message") === true)
|
|
2910
|
-
return void 0;
|
|
2911
|
-
if (rules.headerKept === true) return void 0;
|
|
2912
|
-
const key = keys.find((candidate) => foldKey(candidate) === "message");
|
|
2913
|
-
if (key === void 0 || !keys.some((candidate) => foldKey(candidate) === "stack")) {
|
|
2914
|
-
return void 0;
|
|
2915
|
-
}
|
|
2916
|
-
const text = Reflect.get(source, key);
|
|
2917
|
-
return typeof text === "string" ? { key, text } : void 0;
|
|
2918
|
-
}
|
|
2919
|
-
function readField(source, key, header) {
|
|
2920
|
-
return header !== void 0 && key === header.key ? header.text : Reflect.get(source, key);
|
|
2921
|
-
}
|
|
2922
|
-
function censorAnyName(rules, name) {
|
|
2923
|
-
if (typeof name === "string") return censorName(name, messageCensor(rules));
|
|
2924
|
-
const holder = typeof name === "object" && name !== null || typeof name === "function";
|
|
2925
|
-
return holder && rules.sensitive.has("message") ? rules.censor : name;
|
|
2926
|
-
}
|
|
2927
|
-
function errorTextField(rules, key, value, isError2, header) {
|
|
2928
|
-
if (header !== void 0 && foldKey(key) === "stack" && typeof value === "string") {
|
|
2929
|
-
return hideMessageInStack(value, header.text, rules.censor);
|
|
2930
|
-
}
|
|
2931
|
-
if (!isError2 || !ERROR_TEXT_FIELDS.has(key)) return value;
|
|
2932
|
-
const cut = cutIfText(value);
|
|
2933
|
-
return key === "name" ? censorAnyName(rules, cut) : cut;
|
|
2934
|
-
}
|
|
2935
|
-
|
|
2936
3416
|
// src/server/utils/redact-error-clone.util.ts
|
|
2937
3417
|
function shadowHook(target) {
|
|
2938
|
-
Reflect.defineProperty(target, "toJSON", { value: void 0, configurable: true });
|
|
3418
|
+
Reflect.defineProperty(target, "toJSON", bareDescriptor({ value: void 0, configurable: true }));
|
|
2939
3419
|
}
|
|
2940
3420
|
function withoutEnumerableKeys(clone) {
|
|
2941
3421
|
for (const key of Object.keys(clone)) Reflect.deleteProperty(clone, key);
|
|
2942
3422
|
}
|
|
2943
3423
|
function discardWrite() {
|
|
2944
3424
|
}
|
|
2945
|
-
function
|
|
2946
|
-
const
|
|
2947
|
-
for (const
|
|
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));
|
|
2948
3429
|
descriptor.configurable = true;
|
|
2949
|
-
if ("value"
|
|
3430
|
+
if (Object.hasOwn(descriptor, "value")) descriptor.writable = true;
|
|
2950
3431
|
else descriptor.set ??= discardWrite;
|
|
3432
|
+
Reflect.set(relaxed, key, descriptor);
|
|
2951
3433
|
}
|
|
2952
|
-
|
|
3434
|
+
return relaxed;
|
|
3435
|
+
}
|
|
3436
|
+
function cloneError(error) {
|
|
3437
|
+
const clone = Object.create(
|
|
3438
|
+
Object.getPrototypeOf(error),
|
|
3439
|
+
relaxedDescriptors(Object.getOwnPropertyDescriptors(error))
|
|
3440
|
+
);
|
|
2953
3441
|
const { stack } = error;
|
|
2954
3442
|
if (typeof stack === "string") {
|
|
2955
|
-
Reflect.defineProperty(
|
|
3443
|
+
Reflect.defineProperty(
|
|
3444
|
+
clone,
|
|
3445
|
+
"stack",
|
|
3446
|
+
bareDescriptor({ value: stack, enumerable: false, writable: true })
|
|
3447
|
+
);
|
|
2956
3448
|
}
|
|
2957
3449
|
withoutEnumerableKeys(clone);
|
|
2958
3450
|
shadowHook(clone);
|
|
2959
3451
|
return clone;
|
|
2960
3452
|
}
|
|
2961
|
-
|
|
2962
|
-
// src/server/utils/redact-by-name.util.ts
|
|
2963
|
-
var RAW_HEADER_KEYS = /* @__PURE__ */ new Set(["rawheaders", "rawtrailers"]);
|
|
2964
|
-
function censorHeaderArray(key, walked, rules) {
|
|
2965
|
-
return RAW_HEADER_KEYS.has(key.toLowerCase()) && Array.isArray(walked) ? censorRawHeaders(walked, rules.headerNames, rules.censor) : walked;
|
|
2966
|
-
}
|
|
2967
|
-
var REDACT_MAX_TRAVERSAL_DEPTH = 100;
|
|
2968
|
-
var REDACT_DEPTH_EXCEEDED = "[REDACTION_DEPTH_EXCEEDED]";
|
|
2969
|
-
var REDACT_MAX_VISITS = 2e5;
|
|
2970
|
-
var REDACT_BUDGET_EXCEEDED = "[REDACTION_BUDGET_EXCEEDED]";
|
|
2971
|
-
var REDACT_CIRCULAR = "[Circular]";
|
|
3453
|
+
var MAX_PROTOTYPE_HOPS2 = 256;
|
|
2972
3454
|
function resolveToJson(value, viaGet = false) {
|
|
2973
3455
|
let candidate = viaGet ? Reflect.get(value, "toJSON") : void 0;
|
|
2974
3456
|
let accessor = false;
|
|
2975
3457
|
let proxied = false;
|
|
2976
3458
|
let current = viaGet ? null : value;
|
|
2977
|
-
|
|
3459
|
+
for (let hops = 0; current !== null; hops++) {
|
|
3460
|
+
if (hops > MAX_PROTOTYPE_HOPS2) return { method: void 0, volatile: true, hostile: true };
|
|
2978
3461
|
proxied = proxied || util.types.isProxy(current);
|
|
2979
3462
|
const descriptor = Object.getOwnPropertyDescriptor(current, "toJSON");
|
|
2980
3463
|
if (descriptor !== void 0) {
|
|
2981
|
-
|
|
2982
|
-
|
|
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;
|
|
2983
3468
|
break;
|
|
2984
3469
|
}
|
|
2985
|
-
|
|
3470
|
+
const next = Object.getPrototypeOf(current);
|
|
3471
|
+
current = typeof next === "object" ? next : null;
|
|
2986
3472
|
}
|
|
2987
3473
|
return {
|
|
2988
3474
|
method: typeof candidate === "function" ? candidate : void 0,
|
|
2989
3475
|
volatile: accessor || proxied
|
|
2990
3476
|
};
|
|
2991
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]";
|
|
2992
3489
|
function rulesInside(rules, names, visits) {
|
|
2993
3490
|
return names === void 0 ? void 0 : { ...rules, sensitive: names, visits, insideErrors: void 0 };
|
|
2994
3491
|
}
|
|
@@ -3025,7 +3522,7 @@ function walk(value, rules, depth2, ancestors, honorToJson, inSerialized = false
|
|
|
3025
3522
|
if (++rules.visits.count > rules.maxVisits) {
|
|
3026
3523
|
return REDACT_BUDGET_EXCEEDED;
|
|
3027
3524
|
}
|
|
3028
|
-
if (ancestors
|
|
3525
|
+
if (setHas(ancestors, value)) {
|
|
3029
3526
|
return REDACT_CIRCULAR;
|
|
3030
3527
|
}
|
|
3031
3528
|
if (isError(value)) {
|
|
@@ -3053,7 +3550,8 @@ function walkObject(value, rules, depth2, ancestors, honorToJson, inSerialized)
|
|
|
3053
3550
|
return withBinaryAsSize(value);
|
|
3054
3551
|
}
|
|
3055
3552
|
const resolved = resolveToJson(value, rules.ownFields.safe);
|
|
3056
|
-
|
|
3553
|
+
if (resolved.hostile) return rules.censor;
|
|
3554
|
+
setAdd(ancestors, value);
|
|
3057
3555
|
try {
|
|
3058
3556
|
return walkForm(value, resolved, rules, depth2, ancestors, honorToJson, inSerialized);
|
|
3059
3557
|
} finally {
|
|
@@ -3075,7 +3573,7 @@ function walkForm(value, resolved, rules, depth2, ancestors, honorToJson, inSeri
|
|
|
3075
3573
|
return walkProperties(value, rules, depth2, ancestors, honorToJson, inSerialized);
|
|
3076
3574
|
}
|
|
3077
3575
|
function walkToJsonOutput(value, toJson, rules, depth2, ancestors, inSerialized) {
|
|
3078
|
-
if (Object.keys(value).some((key) => rules.sensitive
|
|
3576
|
+
if (Object.keys(value).some((key) => matchesKey(rules.sensitive, key))) {
|
|
3079
3577
|
return rules.censor;
|
|
3080
3578
|
}
|
|
3081
3579
|
return walk(toJson.call(value), rules, depth2 + 1, ancestors, true, inSerialized);
|
|
@@ -3093,7 +3591,7 @@ function walkProperties(value, rules, depth2, ancestors, honorToJson, inSerializ
|
|
|
3093
3591
|
const current = scrubbed ? ownFieldForLog(source, key, read, rules.ownFields) : read;
|
|
3094
3592
|
const hook = honorToJson && key === "toJSON" && typeof current === "function";
|
|
3095
3593
|
if (current === OMIT_OWN_FIELD || hook) {
|
|
3096
|
-
omitted
|
|
3594
|
+
setAdd(omitted, key);
|
|
3097
3595
|
continue;
|
|
3098
3596
|
}
|
|
3099
3597
|
Reflect.deleteProperty(copy, key);
|
|
@@ -3121,7 +3619,7 @@ function walkProperties(value, rules, depth2, ancestors, honorToJson, inSerializ
|
|
|
3121
3619
|
return copy;
|
|
3122
3620
|
}
|
|
3123
3621
|
function without(keys, omitted) {
|
|
3124
|
-
return keys.filter((key) => !omitted
|
|
3622
|
+
return keys.filter((key) => !setHas(omitted, key));
|
|
3125
3623
|
}
|
|
3126
3624
|
function startCopy(value, asData) {
|
|
3127
3625
|
const clone = isError(value) ? cloneError(value) : void 0;
|
|
@@ -3143,26 +3641,26 @@ function errorPartsHost(rules, ancestors, inSerialized) {
|
|
|
3143
3641
|
}
|
|
3144
3642
|
function createNameRedactor(fieldNames, censor, serializedKeys, maxVisits = REDACT_MAX_VISITS, ownFields = ALL_OWN_FIELDS, errorOnlyNames, headerNames, errorTextToSerializer = false) {
|
|
3145
3643
|
const rules = {
|
|
3146
|
-
sensitive:
|
|
3147
|
-
headerNames:
|
|
3644
|
+
sensitive: foldedNames(fieldNames),
|
|
3645
|
+
headerNames: foldedNames(headerNames ?? fieldNames),
|
|
3148
3646
|
censor,
|
|
3149
|
-
serializedKeys:
|
|
3647
|
+
serializedKeys: capturedSet(serializedKeys),
|
|
3150
3648
|
errorsAsData: serializedKeys !== void 0,
|
|
3151
3649
|
errorTextToSerializer,
|
|
3152
3650
|
maxVisits,
|
|
3153
3651
|
ownFields
|
|
3154
3652
|
};
|
|
3155
|
-
const insideNames = errorOnlyNames === void 0 ? void 0 :
|
|
3653
|
+
const insideNames = errorOnlyNames === void 0 ? void 0 : foldedNames(errorOnlyNames);
|
|
3156
3654
|
return (value, isRecordRoot = false) => {
|
|
3157
3655
|
try {
|
|
3158
3656
|
const visits = { count: 0 };
|
|
3159
|
-
const
|
|
3657
|
+
const call2 = {
|
|
3160
3658
|
...rules,
|
|
3161
3659
|
headerKept: typeof value === "object" && value !== null && errorOutputs.has(value),
|
|
3162
3660
|
visits,
|
|
3163
3661
|
insideErrors: rulesInside(rules, insideNames, visits)
|
|
3164
3662
|
};
|
|
3165
|
-
return walk(value,
|
|
3663
|
+
return walk(value, call2, 0, /* @__PURE__ */ new Set(), !isRecordRoot);
|
|
3166
3664
|
} catch {
|
|
3167
3665
|
return {
|
|
3168
3666
|
_redactionFailed: true,
|
|
@@ -3199,7 +3697,11 @@ function parseResourceAttributes(raw) {
|
|
|
3199
3697
|
} catch {
|
|
3200
3698
|
value = rawValue;
|
|
3201
3699
|
}
|
|
3202
|
-
Object.defineProperty(
|
|
3700
|
+
Object.defineProperty(
|
|
3701
|
+
parsed,
|
|
3702
|
+
key,
|
|
3703
|
+
bareDescriptor({ value, enumerable: true, configurable: true })
|
|
3704
|
+
);
|
|
3203
3705
|
}
|
|
3204
3706
|
return parsed;
|
|
3205
3707
|
}
|
|
@@ -3276,7 +3778,7 @@ function buildResourceBindings(resolved, format, extras = {}) {
|
|
|
3276
3778
|
}
|
|
3277
3779
|
return bindings;
|
|
3278
3780
|
}
|
|
3279
|
-
var OWNED_SERVICE_KEYS =
|
|
3781
|
+
var OWNED_SERVICE_KEYS = capturedSet([
|
|
3280
3782
|
"name",
|
|
3281
3783
|
"version",
|
|
3282
3784
|
"namespace",
|
|
@@ -3423,9 +3925,9 @@ var PATH_SEGMENT = /\[\s*['"]([^'"]+)['"]\s*\]|([^.[\]]+)/g;
|
|
|
3423
3925
|
var INDEX_SEGMENT = /^\d+$/;
|
|
3424
3926
|
function leafNameOf(path) {
|
|
3425
3927
|
let leaf;
|
|
3426
|
-
for (const match of
|
|
3928
|
+
for (const match of allMatches(PATH_SEGMENT, path)) {
|
|
3427
3929
|
const quoted = match[1];
|
|
3428
|
-
const name = quoted ?? (match[2] !== void 0 && INDEX_SEGMENT
|
|
3930
|
+
const name = quoted ?? (match[2] !== void 0 && matchesPattern(INDEX_SEGMENT, match[2]) ? void 0 : match[2]);
|
|
3429
3931
|
if (name !== void 0 && name !== "*") {
|
|
3430
3932
|
leaf = name;
|
|
3431
3933
|
}
|
|
@@ -3452,7 +3954,7 @@ function serializeErrorValue(value_, ownFields = ALL_OWN_FIELDS, censorMessage)
|
|
|
3452
3954
|
return serialized;
|
|
3453
3955
|
}
|
|
3454
3956
|
function toEventName(logKey) {
|
|
3455
|
-
return logKey
|
|
3957
|
+
return replaceAllText(lowerCase(logKey), "_", ".");
|
|
3456
3958
|
}
|
|
3457
3959
|
function withEventName(record, field) {
|
|
3458
3960
|
if (field === false) {
|
|
@@ -3477,7 +3979,7 @@ function resolveRecordRedactor(options) {
|
|
|
3477
3979
|
);
|
|
3478
3980
|
}
|
|
3479
3981
|
function wholeRootKeys(options) {
|
|
3480
|
-
return
|
|
3982
|
+
return capturedSet(["logKey", "err", ...Object.keys(options.serializers)]);
|
|
3481
3983
|
}
|
|
3482
3984
|
function ownFieldPolicyOf(options) {
|
|
3483
3985
|
return createOwnFieldPolicy(options.errorOwnFields, options.errorOwnFieldNames);
|
|
@@ -3516,7 +4018,7 @@ function buildNameRedactor(options, nestedErrorsAsData = false, coversNames = tr
|
|
|
3516
4018
|
);
|
|
3517
4019
|
}
|
|
3518
4020
|
function resolveRedactOption(options) {
|
|
3519
|
-
const paths = options.redactStrategy === "paths" ? compileRedactPaths(options.redactPaths, options.shouldDisableDefaultRedact) : [...
|
|
4021
|
+
const paths = options.redactStrategy === "paths" ? compileRedactPaths(options.redactPaths, options.shouldDisableDefaultRedact) : [...capturedSet(options.redactPaths)];
|
|
3520
4022
|
if (paths.length === 0) {
|
|
3521
4023
|
return void 0;
|
|
3522
4024
|
}
|
|
@@ -3559,6 +4061,10 @@ function buildTraceMixin(logContext, options) {
|
|
|
3559
4061
|
censorMessage: buildMessageCensor(options)
|
|
3560
4062
|
});
|
|
3561
4063
|
}
|
|
4064
|
+
var UNSET_ENTRY_NAMES = {
|
|
4065
|
+
levelVal: void 0,
|
|
4066
|
+
write: void 0
|
|
4067
|
+
};
|
|
3562
4068
|
function buildStreams(options, destinations, health) {
|
|
3563
4069
|
const censorMessage = buildMessageCensor(options);
|
|
3564
4070
|
return destinations.map((destination) => {
|
|
@@ -3570,6 +4076,7 @@ function buildStreams(options, destinations, health) {
|
|
|
3570
4076
|
);
|
|
3571
4077
|
health.registerStream(destination, stream);
|
|
3572
4078
|
return {
|
|
4079
|
+
...UNSET_ENTRY_NAMES,
|
|
3573
4080
|
// Guarded: this runs at provider construction, BEFORE any lifecycle hook, so a
|
|
3574
4081
|
// consumer implementing `minLevel` as a throwing getter would fail the factory
|
|
3575
4082
|
// and the application would never start — earlier than any fail-soft path can
|
|
@@ -3626,10 +4133,24 @@ function buildFormatters(options, redactRecord, redactBindings, onTruncate) {
|
|
|
3626
4133
|
log: buildRecordFormatter(options, redactRecord, onTruncate)
|
|
3627
4134
|
};
|
|
3628
4135
|
}
|
|
3629
|
-
|
|
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");
|
|
3630
4148
|
if (options.maxStringLength !== void 0) {
|
|
3631
4149
|
refuseCensorBeyondLimit(options.redactCensor, options.maxStringLength);
|
|
3632
4150
|
}
|
|
4151
|
+
}
|
|
4152
|
+
function buildPinoInstance(options, logContext, destinations, health) {
|
|
4153
|
+
refuseUnsafeOptions(options);
|
|
3633
4154
|
const redactRecord = resolveRecordRedactor(options);
|
|
3634
4155
|
const redactSerialized = buildNameRedactor(options);
|
|
3635
4156
|
const ownFields = ownFieldPolicyOf(options);
|
|
@@ -3637,10 +4158,10 @@ function buildPinoInstance(options, logContext, destinations, health) {
|
|
|
3637
4158
|
const onTruncate = (reason) => health.recordTruncation(reason);
|
|
3638
4159
|
const pinoOptions = {
|
|
3639
4160
|
level: options.level,
|
|
3640
|
-
...redactOption === void 0 ? {} : { redact: redactOption },
|
|
3641
|
-
|
|
3642
|
-
//
|
|
3643
|
-
// extra attributes
|
|
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.
|
|
3644
4165
|
base: buildResourceBindings(
|
|
3645
4166
|
resolveServiceMetadata(options.service),
|
|
3646
4167
|
options.resourceFormat,
|
|
@@ -3679,7 +4200,7 @@ var DestinationHealth = class {
|
|
|
3679
4200
|
this.entrySizeTruncations = 0;
|
|
3680
4201
|
this.stringLengthTruncations = 0;
|
|
3681
4202
|
/** Destinations whose `onInit()` rejected. Identity-keyed, not name-keyed. */
|
|
3682
|
-
this.failed =
|
|
4203
|
+
this.failed = capturedSet();
|
|
3683
4204
|
/**
|
|
3684
4205
|
* Destinations that initialized, each with its effective level as an index into
|
|
3685
4206
|
* {@link LOG_LEVEL_PRIORITY}.
|
|
@@ -3705,7 +4226,7 @@ var DestinationHealth = class {
|
|
|
3705
4226
|
* for the whole window — coarser than per-entry tracking, and wrong only in the
|
|
3706
4227
|
* direction that duplicates rather than loses.
|
|
3707
4228
|
*/
|
|
3708
|
-
this.writeFailed =
|
|
4229
|
+
this.writeFailed = capturedSet();
|
|
3709
4230
|
/**
|
|
3710
4231
|
* In-flight asynchronous writes per destination.
|
|
3711
4232
|
*
|
|
@@ -3961,20 +4482,21 @@ var HookTimeoutError = class extends Error {
|
|
|
3961
4482
|
}
|
|
3962
4483
|
};
|
|
3963
4484
|
function withTimeout(work, ms) {
|
|
3964
|
-
|
|
4485
|
+
const wait = new IntrinsicPromise((resolve, reject2) => {
|
|
3965
4486
|
const timer = setTimeout(() => {
|
|
3966
4487
|
reject2(new HookTimeoutError(ms));
|
|
3967
4488
|
}, ms);
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
}
|
|
4489
|
+
awaitOutcome(work, (outcome) => {
|
|
4490
|
+
if (outcome.ok) resolve();
|
|
4491
|
+
else reject2(outcome.cause);
|
|
4492
|
+
try {
|
|
4493
|
+
clearTimeout(timer);
|
|
4494
|
+
} catch {
|
|
4495
|
+
}
|
|
4496
|
+
});
|
|
3977
4497
|
});
|
|
4498
|
+
absorb(wait);
|
|
4499
|
+
return tag(wait);
|
|
3978
4500
|
}
|
|
3979
4501
|
|
|
3980
4502
|
// src/server/services/destination-registry.service.ts
|
|
@@ -4024,7 +4546,9 @@ var DestinationRegistry = class {
|
|
|
4024
4546
|
async onModuleInit() {
|
|
4025
4547
|
for (const destination of this.registered) {
|
|
4026
4548
|
try {
|
|
4027
|
-
await
|
|
4549
|
+
await intactOr(
|
|
4550
|
+
withTimeout(() => destination.onInit?.(), this.options.destinationHookTimeoutMs)
|
|
4551
|
+
);
|
|
4028
4552
|
this.active.push(destination);
|
|
4029
4553
|
this.health.markHealthy(destination, this.effectiveLevelOf(destination));
|
|
4030
4554
|
} catch (cause) {
|
|
@@ -4056,14 +4580,16 @@ var DestinationRegistry = class {
|
|
|
4056
4580
|
async notifyRegistryReady() {
|
|
4057
4581
|
for (const destination of this.registered) {
|
|
4058
4582
|
try {
|
|
4059
|
-
await
|
|
4060
|
-
(
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
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
|
+
)
|
|
4067
4593
|
);
|
|
4068
4594
|
} catch (cause) {
|
|
4069
4595
|
this.reportHookFailure(destination, cause);
|
|
@@ -4205,7 +4731,7 @@ var DestinationRegistry = class {
|
|
|
4205
4731
|
continue;
|
|
4206
4732
|
}
|
|
4207
4733
|
try {
|
|
4208
|
-
await withTimeout(() => destination.onShutdown?.(), remaining);
|
|
4734
|
+
await intactOr(withTimeout(() => destination.onShutdown?.(), remaining));
|
|
4209
4735
|
} catch (cause) {
|
|
4210
4736
|
this.reportShutdownFailure(destination, cause);
|
|
4211
4737
|
}
|
|
@@ -4584,7 +5110,7 @@ function productionRefusal() {
|
|
|
4584
5110
|
);
|
|
4585
5111
|
}
|
|
4586
5112
|
async function buildTransform(view) {
|
|
4587
|
-
const { build } = await import('pino-pretty');
|
|
5113
|
+
const { build } = await tag(import('pino-pretty'));
|
|
4588
5114
|
return build({
|
|
4589
5115
|
...DEFAULT_VIEW,
|
|
4590
5116
|
...view,
|
|
@@ -4661,7 +5187,7 @@ var PrettyDevDestination = class {
|
|
|
4661
5187
|
throw productionRefusal();
|
|
4662
5188
|
}
|
|
4663
5189
|
try {
|
|
4664
|
-
this.stream = await buildTransform(this.view);
|
|
5190
|
+
this.stream = await tag(buildTransform(this.view));
|
|
4665
5191
|
} catch (cause) {
|
|
4666
5192
|
this.initFailed = true;
|
|
4667
5193
|
throw initFailure(cause);
|