@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.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,
|
|
@@ -70,21 +87,56 @@ var GROUP_KEYS = {
|
|
|
70
87
|
};
|
|
71
88
|
var GROUP_NAMES = Object.keys(GROUP_KEYS);
|
|
72
89
|
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
90
|
+
var MAX_PROTOTYPE_HOPS = 256;
|
|
91
|
+
function rootHolding(source, key) {
|
|
92
|
+
let hops = 0;
|
|
93
|
+
for (let at = source; at !== null; at = Object.getPrototypeOf(at)) {
|
|
94
|
+
if (hops++ > MAX_PROTOTYPE_HOPS) {
|
|
95
|
+
refuse(
|
|
96
|
+
`[BymaxLoggerModule] options.${key} holds more than ${String(MAX_PROTOTYPE_HOPS)} prototypes`
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
if (Object.hasOwn(at, key)) {
|
|
100
|
+
return at !== source && Object.getPrototypeOf(at) === null ? at : void 0;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return void 0;
|
|
104
|
+
}
|
|
73
105
|
function readSet(source, keys) {
|
|
74
|
-
const set =
|
|
106
|
+
const set = /* @__PURE__ */ Object.create(null);
|
|
75
107
|
for (const key of keys) {
|
|
108
|
+
const root = rootHolding(source, key);
|
|
109
|
+
const planted = root && Object.getOwnPropertyDescriptor(root, key);
|
|
110
|
+
const accessor = planted !== void 0 && Object.hasOwn(planted, "get") && planted.get !== void 0;
|
|
111
|
+
if (accessor) {
|
|
112
|
+
if (types.isProxy(source))
|
|
113
|
+
refuse(
|
|
114
|
+
`[BymaxLoggerModule] options.${key} is read through a Proxy while an accessor of that name is planted on Object.prototype`
|
|
115
|
+
);
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
76
118
|
const value = Reflect.get(source, key);
|
|
119
|
+
if (planted && Object.hasOwn(planted, "value") && Object.is(value, planted.value)) continue;
|
|
77
120
|
if (value !== void 0 && value !== null) Reflect.set(set, key, value);
|
|
78
121
|
}
|
|
79
122
|
return set;
|
|
80
123
|
}
|
|
81
124
|
var LIST_OPTIONS = ["redactPaths", "errorOwnFieldNames", "destinations"];
|
|
82
125
|
var HTTP_LISTS = ["excludePaths", "secretPathSegments"];
|
|
83
|
-
|
|
126
|
+
var MAX_LIST_ENTRIES = 1e4;
|
|
127
|
+
function copyLists(holder, names, prefix) {
|
|
84
128
|
for (const name of names) {
|
|
85
129
|
const value = Reflect.get(holder, name);
|
|
86
130
|
if (!Array.isArray(value)) continue;
|
|
87
131
|
const length = Reflect.get(value, "length");
|
|
132
|
+
if (!Number.isInteger(length) || length < 0) {
|
|
133
|
+
refuse(`[BymaxLoggerModule] options.${prefix}${name} has a length that is not a count`);
|
|
134
|
+
}
|
|
135
|
+
if (length > MAX_LIST_ENTRIES) {
|
|
136
|
+
refuse(
|
|
137
|
+
`[BymaxLoggerModule] options.${prefix}${name} holds more than ${String(MAX_LIST_ENTRIES)} entries`
|
|
138
|
+
);
|
|
139
|
+
}
|
|
88
140
|
Reflect.set(
|
|
89
141
|
holder,
|
|
90
142
|
name,
|
|
@@ -101,32 +153,16 @@ function dropUnsetOptions(options) {
|
|
|
101
153
|
Reflect.set(set, group, readSet(value, Object.keys(Reflect.get(GROUP_KEYS, group))));
|
|
102
154
|
}
|
|
103
155
|
const service = Reflect.get(set, "service");
|
|
104
|
-
if (isRecord(service))
|
|
156
|
+
if (isRecord(service))
|
|
157
|
+
Reflect.set(set, "service", Object.assign(/* @__PURE__ */ Object.create(null), service));
|
|
105
158
|
const serializers = Reflect.get(set, "serializers");
|
|
106
159
|
if (isRecord(serializers)) Reflect.set(set, "serializers", { ...serializers });
|
|
107
|
-
copyLists(set, LIST_OPTIONS);
|
|
160
|
+
copyLists(set, LIST_OPTIONS, "");
|
|
108
161
|
const http = Reflect.get(set, "http");
|
|
109
|
-
if (isRecord(http)) copyLists(http, HTTP_LISTS);
|
|
162
|
+
if (isRecord(http)) copyLists(http, HTTP_LISTS, "http.");
|
|
110
163
|
return set;
|
|
111
164
|
}
|
|
112
165
|
|
|
113
|
-
// src/server/config/options-refusal.util.ts
|
|
114
|
-
var refusals = /* @__PURE__ */ new WeakSet();
|
|
115
|
-
var UNREADABLE = "[BymaxLoggerModule] options could not be read";
|
|
116
|
-
function refuse(message) {
|
|
117
|
-
const error = new Error(message);
|
|
118
|
-
refusals.add(error);
|
|
119
|
-
throw error;
|
|
120
|
-
}
|
|
121
|
-
function guardOptions(read) {
|
|
122
|
-
try {
|
|
123
|
-
return read();
|
|
124
|
-
} catch (error) {
|
|
125
|
-
if (typeof error === "object" && error !== null && refusals.delete(error)) throw error;
|
|
126
|
-
throw new Error(UNREADABLE, { cause: error });
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
166
|
// src/server/constants/lifecycle-timeouts.constants.ts
|
|
131
167
|
var DEFAULT_HOOK_TIMEOUT_MS = 1e4;
|
|
132
168
|
var DEFAULT_SHUTDOWN_TIMEOUT_MS = 1e4;
|
|
@@ -183,7 +219,9 @@ function applyDefaults(given) {
|
|
|
183
219
|
options.otel
|
|
184
220
|
);
|
|
185
221
|
const merged = {
|
|
186
|
-
service: Object.freeze(
|
|
222
|
+
service: Object.freeze(
|
|
223
|
+
Object.assign(/* @__PURE__ */ Object.create(null), options.service)
|
|
224
|
+
),
|
|
187
225
|
level: options.level ?? (isProduction ? "info" : "debug"),
|
|
188
226
|
isGlobal: options.isGlobal ?? true,
|
|
189
227
|
shouldUseAsNestLogger: options.shouldUseAsNestLogger ?? true,
|
|
@@ -289,6 +327,7 @@ function checkGroup(path2, value) {
|
|
|
289
327
|
if (!isRecord2(value)) reject(path2, "must be an object", value);
|
|
290
328
|
return value;
|
|
291
329
|
}
|
|
330
|
+
var MAX_REDACT_PATH_LENGTH = 256;
|
|
292
331
|
var MAX_TIMER_MS = 2147483647;
|
|
293
332
|
function checkTimerMs(path2, value) {
|
|
294
333
|
if (value === void 0) return;
|
|
@@ -403,6 +442,13 @@ function validateCustomization(options) {
|
|
|
403
442
|
if (!isNonEmptyString(entry)) {
|
|
404
443
|
reject(`redactPaths[${String(index)}]`, "must be a non-empty string", entry, true);
|
|
405
444
|
}
|
|
445
|
+
if (entry.length > MAX_REDACT_PATH_LENGTH) {
|
|
446
|
+
reject(
|
|
447
|
+
`redactPaths[${String(index)}]`,
|
|
448
|
+
`must be at most ${String(MAX_REDACT_PATH_LENGTH)} characters`,
|
|
449
|
+
entry
|
|
450
|
+
);
|
|
451
|
+
}
|
|
406
452
|
});
|
|
407
453
|
}
|
|
408
454
|
const serializers = options.serializers;
|
|
@@ -519,8 +565,131 @@ function validateOptions(given) {
|
|
|
519
565
|
validateOtel(options);
|
|
520
566
|
}
|
|
521
567
|
|
|
568
|
+
// src/server/utils/bare-descriptor.util.ts
|
|
569
|
+
var assign = Object.assign;
|
|
570
|
+
function bareDescriptor(descriptor) {
|
|
571
|
+
return assign(/* @__PURE__ */ Object.create(null), descriptor);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
// src/server/utils/captured-builtins.util.ts
|
|
575
|
+
var call = Function.prototype.call;
|
|
576
|
+
var defineProperty = Object.defineProperty;
|
|
577
|
+
var setHas = call.bind(Set.prototype.has);
|
|
578
|
+
var setAdd = call.bind(Set.prototype.add);
|
|
579
|
+
var lowerCase = call.bind(String.prototype.toLowerCase);
|
|
580
|
+
var indexOfText = call.bind(String.prototype.indexOf);
|
|
581
|
+
var sliceText = call.bind(String.prototype.slice);
|
|
582
|
+
function replaceAllText(text, search, replacement) {
|
|
583
|
+
if (search === "") return text;
|
|
584
|
+
let result = "";
|
|
585
|
+
let from = 0;
|
|
586
|
+
for (let at = indexOfText(text, search, 0); at !== -1; at = indexOfText(text, search, from)) {
|
|
587
|
+
result += sliceText(text, from, at) + replacement;
|
|
588
|
+
from = at + search.length;
|
|
589
|
+
}
|
|
590
|
+
return result + sliceText(text, from);
|
|
591
|
+
}
|
|
592
|
+
var normalizeText = call.bind(String.prototype.normalize);
|
|
593
|
+
var regExpExec = call.bind(RegExp.prototype.exec);
|
|
594
|
+
var regExpReplace = call.bind(RegExp.prototype[Symbol.replace]);
|
|
595
|
+
function matchesPattern(pattern, text) {
|
|
596
|
+
return regExpExec(pattern, text) !== null;
|
|
597
|
+
}
|
|
598
|
+
function allMatches(pattern, text) {
|
|
599
|
+
const found = [];
|
|
600
|
+
pattern.lastIndex = 0;
|
|
601
|
+
for (let match = regExpExec(pattern, text); match !== null; match = regExpExec(pattern, text)) {
|
|
602
|
+
if (match[0] === "") break;
|
|
603
|
+
found[found.length] = match;
|
|
604
|
+
}
|
|
605
|
+
pattern.lastIndex = 0;
|
|
606
|
+
return found;
|
|
607
|
+
}
|
|
608
|
+
function replacer(pattern) {
|
|
609
|
+
defineProperty(
|
|
610
|
+
pattern,
|
|
611
|
+
"exec",
|
|
612
|
+
bareDescriptor({ value: (text) => regExpExec(pattern, text) })
|
|
613
|
+
);
|
|
614
|
+
return (text, replacement) => regExpReplace(pattern, text, replacement);
|
|
615
|
+
}
|
|
616
|
+
function capturedSet(values = []) {
|
|
617
|
+
const set = /* @__PURE__ */ new Set();
|
|
618
|
+
const has = (value) => setHas(set, value);
|
|
619
|
+
const add = (value) => {
|
|
620
|
+
setAdd(set, value);
|
|
621
|
+
return set;
|
|
622
|
+
};
|
|
623
|
+
defineProperty(set, "has", bareDescriptor({ value: has }));
|
|
624
|
+
defineProperty(set, "add", bareDescriptor({ value: add }));
|
|
625
|
+
if (Array.isArray(values)) for (let at = 0; at < values.length; at++) add(values[at]);
|
|
626
|
+
else for (const value of values) add(value);
|
|
627
|
+
return set;
|
|
628
|
+
}
|
|
629
|
+
function nextOf(iterator) {
|
|
630
|
+
return Object.getPrototypeOf(iterator);
|
|
631
|
+
}
|
|
632
|
+
var GUARDED_BUILTINS = [
|
|
633
|
+
[Array, ["from", "isArray"]],
|
|
634
|
+
[ArrayBuffer, ["isView"]],
|
|
635
|
+
[Buffer, ["byteLength", "from"]],
|
|
636
|
+
[Buffer.prototype, ["readUInt8", "subarray"]],
|
|
637
|
+
[
|
|
638
|
+
Array.prototype,
|
|
639
|
+
["at", "filter", "flatMap", "forEach", "join", "map", "push", "reduce", "shift", "some", "sort"]
|
|
640
|
+
],
|
|
641
|
+
[Array.prototype, [Symbol.iterator]],
|
|
642
|
+
[String, ["fromCodePoint"]],
|
|
643
|
+
[
|
|
644
|
+
String.prototype,
|
|
645
|
+
["includes", "indexOf", "lastIndexOf", "normalize", "replace", "search", "slice", "split"]
|
|
646
|
+
],
|
|
647
|
+
[String.prototype, ["charCodeAt", "startsWith", "toLowerCase", Symbol.iterator, Symbol.replace]],
|
|
648
|
+
[Map.prototype, ["clear", "get", "has", "set", Symbol.iterator]],
|
|
649
|
+
[Set.prototype, ["add", "delete", "has", "values", Symbol.iterator]],
|
|
650
|
+
[RegExp.prototype, ["exec", "test", Symbol.replace]],
|
|
651
|
+
[
|
|
652
|
+
Object,
|
|
653
|
+
["assign", "create", "defineProperty", "entries", "fromEntries", "getOwnPropertyDescriptor"]
|
|
654
|
+
],
|
|
655
|
+
[Function.prototype, ["call"]],
|
|
656
|
+
[Object, ["getOwnPropertyDescriptors", "getPrototypeOf", "hasOwn", "keys"]],
|
|
657
|
+
[
|
|
658
|
+
Reflect,
|
|
659
|
+
["defineProperty", "deleteProperty", "get", "getOwnPropertyDescriptor", "ownKeys", "set"]
|
|
660
|
+
],
|
|
661
|
+
[Math, ["max", "min"]],
|
|
662
|
+
[Number, ["isInteger"]],
|
|
663
|
+
[nextOf([][Symbol.iterator]()), ["next"]],
|
|
664
|
+
[nextOf(""[Symbol.iterator]()), ["next"]],
|
|
665
|
+
[nextOf((/* @__PURE__ */ new Map())[Symbol.iterator]()), ["next"]],
|
|
666
|
+
[nextOf((/* @__PURE__ */ new Set())[Symbol.iterator]()), ["next"]],
|
|
667
|
+
[nextOf(/(?:)/[Symbol.matchAll]("")), ["next"]]
|
|
668
|
+
];
|
|
669
|
+
var guardedHolders = [];
|
|
670
|
+
var guardedMembers = [];
|
|
671
|
+
var guardedValues = [];
|
|
672
|
+
for (let at = 0; at < GUARDED_BUILTINS.length; at++) {
|
|
673
|
+
const entry = GUARDED_BUILTINS[at];
|
|
674
|
+
for (let member = 0; member < entry[1].length; member++) {
|
|
675
|
+
const name = entry[1][member];
|
|
676
|
+
guardedHolders[guardedHolders.length] = entry[0];
|
|
677
|
+
guardedMembers[guardedMembers.length] = name;
|
|
678
|
+
guardedValues[guardedValues.length] = entry[0][name];
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
function pinoBuiltinsIntact() {
|
|
682
|
+
for (let at = 0; at < guardedHolders.length; at++) {
|
|
683
|
+
if (guardedHolders[at][guardedMembers[at]] !== guardedValues[at]) {
|
|
684
|
+
return false;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
return true;
|
|
688
|
+
}
|
|
689
|
+
|
|
522
690
|
// src/server/config/resolve-options.ts
|
|
523
691
|
function resolveOptions(given) {
|
|
692
|
+
if (!pinoBuiltinsIntact()) throw new Error("LOGGER_BUILTINS_REPLACED");
|
|
524
693
|
return guardOptions(() => {
|
|
525
694
|
const snapshot = dropUnsetOptions(given);
|
|
526
695
|
validateOptions(snapshot);
|
|
@@ -574,7 +743,7 @@ var RESERVED_LOG_KEYS_NOT_EMITTED = Object.freeze({
|
|
|
574
743
|
});
|
|
575
744
|
|
|
576
745
|
// src/server/constants/prototype-polluting-keys.constants.ts
|
|
577
|
-
var PROTOTYPE_POLLUTING_KEYS =
|
|
746
|
+
var PROTOTYPE_POLLUTING_KEYS = capturedSet([
|
|
578
747
|
"__proto__",
|
|
579
748
|
"constructor",
|
|
580
749
|
"prototype"
|
|
@@ -626,70 +795,195 @@ function createEntryTextFinisher(redact, limit, onCut) {
|
|
|
626
795
|
};
|
|
627
796
|
}
|
|
628
797
|
|
|
629
|
-
// src/server/utils/
|
|
630
|
-
var
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
function toSingleLineMessage(text) {
|
|
637
|
-
return text.replace(
|
|
638
|
-
UNSAFE_IN_SINGLE_LINE,
|
|
639
|
-
(char) => LINE_TERMINATORS.has(char) ? "\\n" : toEscapeSequence(char)
|
|
640
|
-
);
|
|
641
|
-
}
|
|
642
|
-
function toBoundedMessage(text) {
|
|
643
|
-
return cutText(toSingleLineMessage(text));
|
|
644
|
-
}
|
|
645
|
-
function escapeControlCharacters(text) {
|
|
646
|
-
return text.replace(UNSAFE_IN_MULTILINE, toEscapeSequence);
|
|
647
|
-
}
|
|
798
|
+
// src/server/utils/glyph-letters.generated.ts
|
|
799
|
+
var GLYPH_LETTER_RUNS = [
|
|
800
|
+
[127312, "abcdefghijklmnopqrstuvwxyz"],
|
|
801
|
+
[127344, "abcdefghijklmnopqrstuvwxyzp"],
|
|
802
|
+
[127397, "d"],
|
|
803
|
+
[127462, "abcdefghijklmnopqrstuvwxyz"]
|
|
804
|
+
];
|
|
648
805
|
|
|
649
806
|
// src/server/utils/fold-key.util.ts
|
|
650
|
-
var
|
|
651
|
-
var
|
|
807
|
+
var dropNotName = replacer(/[^\p{L}\p{N}]|[\u115f\u1160\u3164\uffa0]/gu);
|
|
808
|
+
var SYMBOL_STAND_IN = "\uFFFC";
|
|
809
|
+
var standInSymbols = replacer(/(?=[^\0-\x7f])[\p{So}\p{Sm}\p{Sk}]/gu);
|
|
810
|
+
var dropNotNameStrict = replacer(/[^\p{L}\p{N}\ufffc]|[\u115f\u1160\u3164\uffa0]/gu);
|
|
811
|
+
var GLYPH_LETTERS = new Map(
|
|
812
|
+
GLYPH_LETTER_RUNS.flatMap(
|
|
813
|
+
([first, letters]) => [...letters].map((letter, index) => [
|
|
814
|
+
String.fromCodePoint(first + index),
|
|
815
|
+
letter
|
|
816
|
+
])
|
|
817
|
+
)
|
|
818
|
+
);
|
|
819
|
+
function readGlyphs(text) {
|
|
820
|
+
return Array.from(text, (glyph) => GLYPH_LETTERS.get(glyph) ?? glyph).join("");
|
|
821
|
+
}
|
|
822
|
+
var dropInvisible = replacer(/[\s\p{Cc}\p{Cf}\p{M}\u115f\u1160\u2800\u3164\uffa0]/gu);
|
|
823
|
+
var readDots = replacer(/[\u3002\u0701\u06d4\u22c5\u00b7\ufe12]/gu);
|
|
652
824
|
var PLAIN = /^[\x21-\x7e]*$/;
|
|
825
|
+
var NON_ASCII = /[^\x20-\x7e]/;
|
|
826
|
+
var dropNotAscii = replacer(/[^A-Za-z0-9]/g);
|
|
653
827
|
var LOOKALIKES = new Map(
|
|
654
828
|
Object.entries({
|
|
655
829
|
a: "\u0430\u03B1\u1D00",
|
|
656
830
|
b: "\u0299",
|
|
657
|
-
c: "\u0441\u03F2\u1D04",
|
|
831
|
+
c: "\u0441\u03F2\u1D04\u023C\u0188",
|
|
658
832
|
d: "\u0501\u1D05",
|
|
659
|
-
e: "\u0435\u03B5\u03F5\u1D07",
|
|
833
|
+
e: "\u0435\u03B5\u03F5\u1D07\u025B\u04BD",
|
|
660
834
|
f: "\uA730",
|
|
661
835
|
g: "\u0262",
|
|
662
836
|
h: "\u029C",
|
|
663
|
-
i: "\u0456\u03B9\u0131\u026A",
|
|
664
837
|
j: "\u0458\u1D0A",
|
|
665
838
|
k: "\u1D0B",
|
|
666
839
|
l: "\u029F",
|
|
667
840
|
m: "\u1D0D",
|
|
668
841
|
n: "\u0274",
|
|
669
|
-
o: "\u043E\u03BF\u1D0F",
|
|
670
|
-
p: "\u0440\u03C1\u1D18",
|
|
842
|
+
o: "\u043E\u03BF\u1D0F\xF8",
|
|
843
|
+
p: "\u0440\u03C1\u1D18\u01BF",
|
|
671
844
|
q: "\u051B",
|
|
672
845
|
r: "\u0280",
|
|
673
846
|
s: "\u0455\uA731",
|
|
674
|
-
t: "\u1D1B",
|
|
847
|
+
t: "\u1D1B\u0167",
|
|
675
848
|
u: "\u1D1C",
|
|
676
|
-
v: "\
|
|
849
|
+
v: "\u1D20",
|
|
677
850
|
w: "\u051D\u1D21",
|
|
678
851
|
x: "\u0445",
|
|
679
|
-
y: "\u0443\u028F",
|
|
852
|
+
y: "\u0443\u028F\u04AF",
|
|
680
853
|
z: "\u1D22"
|
|
681
854
|
}).flatMap(([latin, letters]) => [...letters].map((letter) => [letter, latin]))
|
|
682
855
|
);
|
|
856
|
+
var LOOKALIKE_PAIRS = Array.from(LOOKALIKES);
|
|
857
|
+
var I_LIKE = new Map(
|
|
858
|
+
[..."\u0456\u03B9\u0131\u026A\u0269"].map((letter) => [letter, "i"])
|
|
859
|
+
);
|
|
860
|
+
var I_LIKE_PAIRS = Array.from(I_LIKE);
|
|
683
861
|
function foldKey(key, keepSeparators = false) {
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
862
|
+
if (keepSeparators) {
|
|
863
|
+
if (matchesPattern(PLAIN, key)) return lowerCase(key);
|
|
864
|
+
return withLookalikes(
|
|
865
|
+
dropInvisible(readDots(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), "."), ""),
|
|
866
|
+
true
|
|
867
|
+
);
|
|
868
|
+
}
|
|
869
|
+
if (matchesPattern(PLAIN, key)) return lowerCase(dropNotAscii(key, ""));
|
|
870
|
+
return withLookalikes(dropNotName(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), ""), true);
|
|
871
|
+
}
|
|
872
|
+
function foldStrict(key) {
|
|
873
|
+
if (matchesPattern(PLAIN, key)) return lowerCase(dropNotAscii(key, ""));
|
|
874
|
+
return withLookalikes(
|
|
875
|
+
dropNotNameStrict(
|
|
876
|
+
standInSymbols(readGlyphs(lowerCase(normalizeText(key, "NFKD"))), SYMBOL_STAND_IN),
|
|
877
|
+
""
|
|
878
|
+
),
|
|
879
|
+
false
|
|
880
|
+
);
|
|
881
|
+
}
|
|
882
|
+
function withLookalikes(folded, all) {
|
|
883
|
+
let read = folded;
|
|
884
|
+
for (let at = 0; at < LOOKALIKE_PAIRS.length; at++) {
|
|
885
|
+
const [letter, latin] = LOOKALIKE_PAIRS[at];
|
|
886
|
+
read = replaceAllText(read, letter, latin);
|
|
887
|
+
}
|
|
888
|
+
if (all) {
|
|
889
|
+
for (let at = 0; at < I_LIKE_PAIRS.length; at++) {
|
|
890
|
+
const [letter, latin] = I_LIKE_PAIRS[at];
|
|
891
|
+
read = replaceAllText(read, letter, latin);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
return read;
|
|
895
|
+
}
|
|
896
|
+
var ALNUM = /^[A-Za-z0-9]*$/;
|
|
897
|
+
function formOf(key) {
|
|
898
|
+
return matchesPattern(ALNUM, key) ? lowerCase(key) : foldStrict(key);
|
|
899
|
+
}
|
|
900
|
+
var answers = /* @__PURE__ */ new WeakMap();
|
|
901
|
+
function foldName(key) {
|
|
902
|
+
return formOf(key);
|
|
903
|
+
}
|
|
904
|
+
function foldedNames(names) {
|
|
905
|
+
return capturedSet(
|
|
906
|
+
Array.from(names, (name) => replaceAllText(foldName(name), SYMBOL_STAND_IN, "")).filter(
|
|
907
|
+
(name) => name !== ""
|
|
908
|
+
)
|
|
909
|
+
);
|
|
910
|
+
}
|
|
911
|
+
var MAX_CANDIDATES = 64;
|
|
912
|
+
var grouped = /* @__PURE__ */ new WeakMap();
|
|
913
|
+
function groupsOf(names) {
|
|
914
|
+
let groups = grouped.get(names);
|
|
915
|
+
if (groups === void 0) {
|
|
916
|
+
const built = /* @__PURE__ */ new Map();
|
|
917
|
+
let longest = 0;
|
|
918
|
+
for (const name of names) {
|
|
919
|
+
const size = [...name].length;
|
|
920
|
+
const same = built.get(size);
|
|
921
|
+
if (same === void 0) built.set(size, [name]);
|
|
922
|
+
else same.push(name);
|
|
923
|
+
longest = Math.max(longest, size);
|
|
924
|
+
}
|
|
925
|
+
groups = { byLength: built, longest };
|
|
926
|
+
grouped.set(names, groups);
|
|
927
|
+
}
|
|
928
|
+
return groups;
|
|
929
|
+
}
|
|
930
|
+
function matchesFolded(names, folded) {
|
|
931
|
+
if (names.has(folded)) return true;
|
|
932
|
+
if (!matchesPattern(NON_ASCII, folded)) return false;
|
|
933
|
+
const letters = [...folded];
|
|
934
|
+
const wide = letters.filter((letter) => !isAscii(letter)).length;
|
|
935
|
+
const stands = letters.filter((letter) => letter === SYMBOL_STAND_IN).length;
|
|
936
|
+
const { byLength, longest } = groupsOf(names);
|
|
937
|
+
if (longest === 0) return false;
|
|
938
|
+
if (stands > longest) return true;
|
|
939
|
+
if (letters.length - stands > longest) return false;
|
|
940
|
+
const lengths = Array.from(
|
|
941
|
+
{ length: wide + stands + 1 },
|
|
942
|
+
(_, extra) => byLength.get(letters.length - stands + extra) ?? []
|
|
943
|
+
);
|
|
944
|
+
if (lengths.reduce((count, same) => count + same.length, 0) > MAX_CANDIDATES) return true;
|
|
945
|
+
return lengths.some((same) => same.some((name) => matchesName(letters, [...name])));
|
|
946
|
+
}
|
|
947
|
+
var isAscii = (letter) => letter < "\x80";
|
|
948
|
+
function matchesName(letters, name) {
|
|
949
|
+
const initial = /* @__PURE__ */ new Set();
|
|
950
|
+
setAdd(initial, 0);
|
|
951
|
+
let at = initial;
|
|
952
|
+
for (const letter of letters) {
|
|
953
|
+
const next = /* @__PURE__ */ new Set();
|
|
954
|
+
for (const position of at) {
|
|
955
|
+
if (letter === SYMBOL_STAND_IN) {
|
|
956
|
+
setAdd(next, position);
|
|
957
|
+
setAdd(next, position + 1);
|
|
958
|
+
setAdd(next, position + 2);
|
|
959
|
+
continue;
|
|
960
|
+
}
|
|
961
|
+
if (isAscii(letter)) {
|
|
962
|
+
if (name[position] === letter) setAdd(next, position + 1);
|
|
963
|
+
continue;
|
|
964
|
+
}
|
|
965
|
+
setAdd(next, position + 1);
|
|
966
|
+
setAdd(next, position + 2);
|
|
967
|
+
}
|
|
968
|
+
at = next;
|
|
969
|
+
}
|
|
970
|
+
return setHas(at, name.length);
|
|
971
|
+
}
|
|
972
|
+
function matchesKey(names, key) {
|
|
973
|
+
const seen = answers.get(names) ?? /* @__PURE__ */ new Map();
|
|
974
|
+
answers.set(names, seen);
|
|
975
|
+
const known = seen.get(key);
|
|
976
|
+
if (known !== void 0) return known;
|
|
977
|
+
const folded = formOf(key);
|
|
978
|
+
const answer = names.has(folded) || matchesFolded(names, folded);
|
|
979
|
+
if (key.length <= 64) {
|
|
980
|
+
if (seen.size > 1023) seen.clear();
|
|
981
|
+
seen.set(key, answer);
|
|
982
|
+
}
|
|
983
|
+
return answer;
|
|
689
984
|
}
|
|
690
985
|
|
|
691
986
|
// src/server/utils/hide-message-in-stack.util.ts
|
|
692
|
-
var FRAME_LINE = /\n[ \t]+at /g;
|
|
693
987
|
function failureTable(message) {
|
|
694
988
|
const table = new Int32Array(message.length);
|
|
695
989
|
for (let i = 1, matched = 0; i < message.length; i += 1) {
|
|
@@ -700,6 +994,7 @@ function failureTable(message) {
|
|
|
700
994
|
return table;
|
|
701
995
|
}
|
|
702
996
|
function occurrences(stack, message) {
|
|
997
|
+
if (message.length > stack.length) return [];
|
|
703
998
|
const table = failureTable(message);
|
|
704
999
|
const spans = [];
|
|
705
1000
|
for (let i = 0, matched = 0; i < stack.length; i += 1) {
|
|
@@ -714,37 +1009,23 @@ function occurrences(stack, message) {
|
|
|
714
1009
|
}
|
|
715
1010
|
return spans;
|
|
716
1011
|
}
|
|
717
|
-
function
|
|
718
|
-
|
|
719
|
-
for (const line of stack.matchAll(FRAME_LINE)) {
|
|
720
|
-
while (next < spans.length && spans[next][1] <= line.index) next += 1;
|
|
721
|
-
const span = spans[next];
|
|
722
|
-
if (span === void 0 || line.index < span[0]) return line.index;
|
|
723
|
-
}
|
|
724
|
-
return stack.length;
|
|
725
|
-
}
|
|
726
|
-
function hideMessageInStack(stack, message, replacement) {
|
|
727
|
-
if (message === "") return stack;
|
|
728
|
-
if (message.length > stack.length) return stack;
|
|
729
|
-
const spans = occurrences(stack, message);
|
|
730
|
-
const end = headerEnd(stack, spans);
|
|
1012
|
+
function hideMessagesInStack(stack, messages, replacement, limit) {
|
|
1013
|
+
const spans = messages.filter((message) => message !== "").flatMap((message) => occurrences(stack, message)).sort((a, b) => a[0] - b[0]);
|
|
731
1014
|
let result = "";
|
|
732
1015
|
let from = 0;
|
|
733
|
-
|
|
1016
|
+
let end = limit;
|
|
1017
|
+
for (const [start, stop] of spans) {
|
|
1018
|
+
if (start >= end) break;
|
|
1019
|
+
if (start < from) {
|
|
1020
|
+
from = Math.max(from, stop);
|
|
1021
|
+
end = Math.max(end, from);
|
|
1022
|
+
continue;
|
|
1023
|
+
}
|
|
734
1024
|
result += stack.slice(from, start) + replacement;
|
|
735
1025
|
from = stop;
|
|
1026
|
+
end = Math.max(end, stop);
|
|
736
1027
|
}
|
|
737
|
-
return result + stack.slice(from);
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
// src/server/utils/is-plain-record.util.ts
|
|
741
|
-
function isPlainRecord(node) {
|
|
742
|
-
try {
|
|
743
|
-
const prototype = Object.getPrototypeOf(node);
|
|
744
|
-
return prototype === Object.prototype || prototype === null;
|
|
745
|
-
} catch {
|
|
746
|
-
return false;
|
|
747
|
-
}
|
|
1028
|
+
return result + stack.slice(from, Math.max(end, from));
|
|
748
1029
|
}
|
|
749
1030
|
|
|
750
1031
|
// src/server/utils/censor-stack-header.util.ts
|
|
@@ -753,17 +1034,37 @@ function endsHeader(stack, message, from) {
|
|
|
753
1034
|
const end = from + message.length;
|
|
754
1035
|
return stack.startsWith(message, from) && (end === stack.length || stack.startsWith("\n", end));
|
|
755
1036
|
}
|
|
756
|
-
function
|
|
757
|
-
if (message === "" || censored === message) return stack;
|
|
1037
|
+
function splitCensoredHeader(stack, name, message, censored) {
|
|
1038
|
+
if (message === "" || censored === message) return ["", stack];
|
|
758
1039
|
const separator = stack.indexOf(NAME_SEPARATOR);
|
|
759
1040
|
if (separator !== -1 && stack.lastIndexOf("\n", separator) === -1) {
|
|
760
1041
|
const from = separator + NAME_SEPARATOR.length;
|
|
761
1042
|
if (endsHeader(stack, message, from)) {
|
|
762
|
-
return stack.slice(0, from) + censored
|
|
1043
|
+
return [stack.slice(0, from) + censored, stack.slice(from + message.length)];
|
|
763
1044
|
}
|
|
764
1045
|
}
|
|
765
|
-
if (endsHeader(stack, message, 0)) return censored
|
|
766
|
-
return name === "" ? censored : name + NAME_SEPARATOR + censored;
|
|
1046
|
+
if (endsHeader(stack, message, 0)) return [censored, stack.slice(message.length)];
|
|
1047
|
+
return [name === "" ? censored : name + NAME_SEPARATOR + censored, ""];
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
// src/server/utils/escape-log-text.util.ts
|
|
1051
|
+
var LINE_TERMINATORS = capturedSet(["\r", "\n", "\x85", "\u2028", "\u2029"]);
|
|
1052
|
+
var UNSAFE_IN_SINGLE_LINE = /[\u0000-\u0008\u000A-\u001F\u007F-\u009F\u2028\u2029\p{Cs}]/gu;
|
|
1053
|
+
var UNSAFE_IN_MULTILINE = /[\u0000-\u0008\u000B-\u001F\u007F-\u009F\u2028\u2029\p{Cs}]/gu;
|
|
1054
|
+
function toEscapeSequence(char) {
|
|
1055
|
+
return `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`;
|
|
1056
|
+
}
|
|
1057
|
+
function toSingleLineMessage(text) {
|
|
1058
|
+
return text.replace(
|
|
1059
|
+
UNSAFE_IN_SINGLE_LINE,
|
|
1060
|
+
(char) => LINE_TERMINATORS.has(char) ? "\\n" : toEscapeSequence(char)
|
|
1061
|
+
);
|
|
1062
|
+
}
|
|
1063
|
+
function toBoundedMessage(text) {
|
|
1064
|
+
return cutText(toSingleLineMessage(text));
|
|
1065
|
+
}
|
|
1066
|
+
function escapeControlCharacters(text) {
|
|
1067
|
+
return text.replace(UNSAFE_IN_MULTILINE, toEscapeSequence);
|
|
767
1068
|
}
|
|
768
1069
|
function isError(value) {
|
|
769
1070
|
try {
|
|
@@ -788,17 +1089,17 @@ var DEFAULT_SAFE_ERROR_FIELDS = [
|
|
|
788
1089
|
"schema",
|
|
789
1090
|
"routine"
|
|
790
1091
|
];
|
|
791
|
-
var DERIVED_ERROR_FIELDS =
|
|
1092
|
+
var DERIVED_ERROR_FIELDS = capturedSet([
|
|
792
1093
|
"name",
|
|
793
1094
|
"message",
|
|
794
1095
|
"stack",
|
|
795
1096
|
"cause",
|
|
796
1097
|
"errors"
|
|
797
1098
|
]);
|
|
798
|
-
var ALL_OWN_FIELDS = { safe: false, names:
|
|
1099
|
+
var ALL_OWN_FIELDS = { safe: false, names: capturedSet() };
|
|
799
1100
|
function createOwnFieldPolicy(mode, extraNames) {
|
|
800
1101
|
if (mode === "all") return ALL_OWN_FIELDS;
|
|
801
|
-
return { safe: true, names:
|
|
1102
|
+
return { safe: true, names: capturedSet([...DEFAULT_SAFE_ERROR_FIELDS, ...extraNames]) };
|
|
802
1103
|
}
|
|
803
1104
|
function allowsOwnField(policy, key) {
|
|
804
1105
|
return !policy.safe || DERIVED_ERROR_FIELDS.has(key) || key === "_errorFieldsIncomplete" || policy.names.has(key);
|
|
@@ -852,12 +1153,12 @@ function readScrubbedStack(value, name, message, textName, result, walk2) {
|
|
|
852
1153
|
const header = headerCensor(name, message, walk2.censorMessage);
|
|
853
1154
|
return textName ? scrubStack(stack, header) : scrubStack(withNamedHeader(stack, message), header, stack.length > MAX_STACK_SCAN);
|
|
854
1155
|
}
|
|
855
|
-
var
|
|
1156
|
+
var FRAME_LINE = /\n[ \t]+at /;
|
|
856
1157
|
function withNamedHeader(stack, message) {
|
|
857
1158
|
const head = stack.slice(0, MAX_STACK_SCAN);
|
|
858
1159
|
const found = message === "" ? -1 : head.indexOf(message);
|
|
859
1160
|
if (found !== -1) return `Error: ${head.slice(found)}`;
|
|
860
|
-
const end = head.search(
|
|
1161
|
+
const end = head.search(FRAME_LINE);
|
|
861
1162
|
const frames = end === -1 ? "" : head.slice(end);
|
|
862
1163
|
return `Error${message === "" ? "" : `: ${message}`}${frames}`;
|
|
863
1164
|
}
|
|
@@ -895,26 +1196,30 @@ function toSanitizedError(value, seen, depth2, walk2) {
|
|
|
895
1196
|
return { name: "SanitizeFailed", message: "Failed to sanitize the thrown value" };
|
|
896
1197
|
}
|
|
897
1198
|
}
|
|
898
|
-
var ARGUMENT_FIELDS =
|
|
899
|
-
var DATABASE_VALUE_FIELDS =
|
|
1199
|
+
var ARGUMENT_FIELDS = capturedSet(["args", "parameters"]);
|
|
1200
|
+
var DATABASE_VALUE_FIELDS = capturedSet(["detail", "where", "internalQuery"]);
|
|
900
1201
|
var SQLSTATE = /^[0-9A-DF-Z][0-9A-Z]{4}$/;
|
|
901
1202
|
var OMIT_OWN_FIELD = /* @__PURE__ */ Symbol("omit-own-field");
|
|
1203
|
+
function ownDataValue(source, key) {
|
|
1204
|
+
const descriptor = Object.getOwnPropertyDescriptor(source, key);
|
|
1205
|
+
return descriptor !== void 0 && Object.hasOwn(descriptor, "value") ? descriptor.value : void 0;
|
|
1206
|
+
}
|
|
902
1207
|
function isDatabaseError(source) {
|
|
903
|
-
const code =
|
|
904
|
-
return typeof code === "string" && SQLSTATE
|
|
1208
|
+
const code = ownDataValue(source, "code");
|
|
1209
|
+
return typeof code === "string" && matchesPattern(SQLSTATE, code);
|
|
905
1210
|
}
|
|
906
1211
|
function ownFieldForLog(source, key, value, policy = ALL_OWN_FIELDS) {
|
|
907
1212
|
if (!allowsOwnField(policy, key)) return OMIT_OWN_FIELD;
|
|
908
|
-
if (ARGUMENT_FIELDS.has(key
|
|
1213
|
+
if (ARGUMENT_FIELDS.has(lowerCase(key))) return OMIT_OWN_FIELD;
|
|
909
1214
|
if (DATABASE_VALUE_FIELDS.has(key) && isDatabaseError(source)) return OMIT_OWN_FIELD;
|
|
910
1215
|
if (key !== "command" || typeof value !== "object" || value === null) {
|
|
911
1216
|
return withBinaryAsSize(value);
|
|
912
1217
|
}
|
|
913
|
-
const name =
|
|
1218
|
+
const name = ownDataValue(value, "name");
|
|
914
1219
|
return typeof name === "string" ? { name } : OMIT_OWN_FIELD;
|
|
915
1220
|
}
|
|
916
1221
|
function defineErrorField(target, key, value) {
|
|
917
|
-
Object.defineProperty(target, key, { value, enumerable: true });
|
|
1222
|
+
Object.defineProperty(target, key, bareDescriptor({ value, enumerable: true }));
|
|
918
1223
|
}
|
|
919
1224
|
function assignOwnErrorFields(target, source, policy = ALL_OWN_FIELDS) {
|
|
920
1225
|
try {
|
|
@@ -931,7 +1236,11 @@ function assignOwnErrorFields(target, source, policy = ALL_OWN_FIELDS) {
|
|
|
931
1236
|
}
|
|
932
1237
|
}
|
|
933
1238
|
function markIncomplete(target) {
|
|
934
|
-
Reflect.defineProperty(
|
|
1239
|
+
Reflect.defineProperty(
|
|
1240
|
+
target,
|
|
1241
|
+
"_errorFieldsIncomplete",
|
|
1242
|
+
bareDescriptor({ value: true, enumerable: true })
|
|
1243
|
+
);
|
|
935
1244
|
}
|
|
936
1245
|
function readOptional(read, node) {
|
|
937
1246
|
try {
|
|
@@ -966,7 +1275,7 @@ var MAX_PLAIN_NAME = 64;
|
|
|
966
1275
|
var PLAIN_NAME = /^[A-Za-z_$][\w$.-]*$/;
|
|
967
1276
|
function censorName(name, censorMessage) {
|
|
968
1277
|
if (censorMessage === void 0 || name === "") return name;
|
|
969
|
-
if (name.length <= MAX_PLAIN_NAME && PLAIN_NAME
|
|
1278
|
+
if (name.length <= MAX_PLAIN_NAME && matchesPattern(PLAIN_NAME, name)) return name;
|
|
970
1279
|
try {
|
|
971
1280
|
return censorMessage(name);
|
|
972
1281
|
} catch {
|
|
@@ -986,15 +1295,24 @@ function headerCensor(name, message, censorMessage) {
|
|
|
986
1295
|
function censorStackName(stack, header) {
|
|
987
1296
|
return header.name !== "" && stack.startsWith(header.name) ? header.censoredName + stack.slice(header.name.length) : stack;
|
|
988
1297
|
}
|
|
1298
|
+
function censorMessageInStack(stack, header) {
|
|
1299
|
+
const [opened, rest] = splitCensoredHeader(
|
|
1300
|
+
censorStackName(stack, header),
|
|
1301
|
+
header.censoredName,
|
|
1302
|
+
header.message,
|
|
1303
|
+
header.censored
|
|
1304
|
+
);
|
|
1305
|
+
return header.censored === header.message ? opened + rest : opened + hideMessagesInStack(
|
|
1306
|
+
rest,
|
|
1307
|
+
[header.message],
|
|
1308
|
+
header.censored,
|
|
1309
|
+
Math.max(0, MAX_STACK_SCAN - (stack.length - rest.length))
|
|
1310
|
+
);
|
|
1311
|
+
}
|
|
989
1312
|
function scrubStack(stack, header, wasLonger = false) {
|
|
990
|
-
const
|
|
1313
|
+
const window = stack.slice(0, MAX_STACK_SCAN + (header?.message.length ?? 0));
|
|
991
1314
|
const scrubbed = escapeControlCharacters(
|
|
992
|
-
(header === void 0 ?
|
|
993
|
-
censorStackName(head, header),
|
|
994
|
-
header.censoredName,
|
|
995
|
-
header.message,
|
|
996
|
-
header.censored
|
|
997
|
-
)).split("\n").filter((line) => !line.includes("node_modules")).join("\n")
|
|
1315
|
+
(header === void 0 ? window : censorMessageInStack(window, header)).slice(0, MAX_STACK_SCAN).split("\n").filter((line) => !line.includes("node_modules")).join("\n")
|
|
998
1316
|
);
|
|
999
1317
|
return cutText(scrubbed, wasLonger || stack.length > MAX_STACK_SCAN);
|
|
1000
1318
|
}
|
|
@@ -1008,6 +1326,178 @@ function createWidthMarker(omitted) {
|
|
|
1008
1326
|
return { _truncated: true, _reason: "aggregate-width-exceeded", _omitted: omitted };
|
|
1009
1327
|
}
|
|
1010
1328
|
|
|
1329
|
+
// src/server/utils/redact-error-parts.util.ts
|
|
1330
|
+
function defineOwn(target, key, value) {
|
|
1331
|
+
Reflect.defineProperty(target, key, bareDescriptor({ value, enumerable: true, writable: true }));
|
|
1332
|
+
}
|
|
1333
|
+
var linkDepths = /* @__PURE__ */ new WeakMap();
|
|
1334
|
+
var ERROR_TEXT_FIELDS = capturedSet(["name", "message", "stack"]);
|
|
1335
|
+
var INCOMPLETE_KEY = "_errorFieldsIncomplete";
|
|
1336
|
+
var widthMarkers = /* @__PURE__ */ new WeakSet();
|
|
1337
|
+
function capErrors(errors, host) {
|
|
1338
|
+
if (!Array.isArray(errors) || errors.length <= MAX_AGGREGATE_ERRORS) return errors;
|
|
1339
|
+
if (host.hasToJson(errors)) return errors;
|
|
1340
|
+
const kept = [];
|
|
1341
|
+
for (let index = 0; index < MAX_AGGREGATE_ERRORS; index++) kept.push(Reflect.get(errors, index));
|
|
1342
|
+
const marker = createWidthMarker(errors.length - MAX_AGGREGATE_ERRORS);
|
|
1343
|
+
widthMarkers.add(marker);
|
|
1344
|
+
kept.push(marker);
|
|
1345
|
+
return kept;
|
|
1346
|
+
}
|
|
1347
|
+
function linkTargets(value) {
|
|
1348
|
+
const targets = [];
|
|
1349
|
+
const take = (link) => {
|
|
1350
|
+
if (typeof link === "object" && link !== null) targets.push(link);
|
|
1351
|
+
};
|
|
1352
|
+
if (!Array.isArray(value)) take(value);
|
|
1353
|
+
else for (let index = 0; index < value.length; index++) take(Reflect.get(value, index));
|
|
1354
|
+
return targets;
|
|
1355
|
+
}
|
|
1356
|
+
function walkChainPart(value, level, host, depth2) {
|
|
1357
|
+
const targets = linkTargets(value);
|
|
1358
|
+
if (targets.length > 0 && level + 1 > DEFAULT_MAX_CAUSE_DEPTH) {
|
|
1359
|
+
if (Array.isArray(value) && host.nameKey === "name") {
|
|
1360
|
+
return Array.from({ length: value.length }, (_member, index) => {
|
|
1361
|
+
const member = Reflect.get(value, index);
|
|
1362
|
+
return typeof member === "object" && member !== null && widthMarkers.has(member) ? member : createDepthMarker();
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
return createDepthMarker();
|
|
1366
|
+
}
|
|
1367
|
+
const before = new Map(targets.map((target) => [target, linkDepths.get(target)]));
|
|
1368
|
+
for (const target of targets) linkDepths.set(target, level + 1);
|
|
1369
|
+
try {
|
|
1370
|
+
return host.walk(value, depth2 + 1);
|
|
1371
|
+
} finally {
|
|
1372
|
+
before.forEach((earlier, target) => {
|
|
1373
|
+
if (earlier === void 0) linkDepths.delete(target);
|
|
1374
|
+
else linkDepths.set(target, earlier);
|
|
1375
|
+
});
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
function cutOrWalk(value, level, host, depth2) {
|
|
1379
|
+
return typeof value === "string" ? cutText(value) : walkChainPart(value, level, host, depth2);
|
|
1380
|
+
}
|
|
1381
|
+
function writeName(value, level, host, depth2) {
|
|
1382
|
+
const censored = host.censorName(typeof value === "string" ? cutText(value) : value);
|
|
1383
|
+
return censored === value ? cutOrWalk(value, level, host, depth2) : censored;
|
|
1384
|
+
}
|
|
1385
|
+
function addErrorParts(copy, error, ownKeys, host, depth2) {
|
|
1386
|
+
const taken = capturedSet(ownKeys);
|
|
1387
|
+
const level = linkDepths.get(error) ?? 0;
|
|
1388
|
+
let incomplete = false;
|
|
1389
|
+
const add = (key, covers, read, write = (value) => walkChainPart(value, level, host, depth2)) => {
|
|
1390
|
+
if (taken.has(key)) return;
|
|
1391
|
+
try {
|
|
1392
|
+
const written = write(read());
|
|
1393
|
+
if (written === void 0) return;
|
|
1394
|
+
const covered = covers.some((name) => host.sensitive.has(name));
|
|
1395
|
+
defineOwn(copy, key, covered ? host.censor : written);
|
|
1396
|
+
} catch {
|
|
1397
|
+
incomplete = true;
|
|
1398
|
+
}
|
|
1399
|
+
};
|
|
1400
|
+
add(
|
|
1401
|
+
host.nameKey,
|
|
1402
|
+
[host.nameKey, "name"],
|
|
1403
|
+
() => error.name,
|
|
1404
|
+
(name) => writeName(name, level, host, depth2)
|
|
1405
|
+
);
|
|
1406
|
+
add(
|
|
1407
|
+
"message",
|
|
1408
|
+
["message"],
|
|
1409
|
+
() => error.message,
|
|
1410
|
+
(message) => cutOrWalk(message, level, host, depth2)
|
|
1411
|
+
);
|
|
1412
|
+
add(
|
|
1413
|
+
"stack",
|
|
1414
|
+
["stack", "name", "message"],
|
|
1415
|
+
() => error.stack,
|
|
1416
|
+
(stack) => typeof stack === "string" ? scrubStack(stack) : void 0
|
|
1417
|
+
);
|
|
1418
|
+
add("cause", ["cause"], () => error.cause);
|
|
1419
|
+
add("errors", ["errors"], () => capErrors(error.errors, host));
|
|
1420
|
+
if (incomplete && !taken.has(INCOMPLETE_KEY)) defineOwn(copy, INCOMPLETE_KEY, true);
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
// src/server/utils/error-text-exemption.util.ts
|
|
1424
|
+
var ERROR_TEXT_KEYS = capturedSet(["message"]);
|
|
1425
|
+
function leavesErrorText(rules, key, value, honorToJson) {
|
|
1426
|
+
return rules.errorTextToSerializer && !honorToJson && key === "err" && !Array.isArray(value);
|
|
1427
|
+
}
|
|
1428
|
+
function rulesBelow(rules, key, value, honorToJson) {
|
|
1429
|
+
if (leavesErrorText(rules, key, value, honorToJson)) {
|
|
1430
|
+
return { ...rules, exemptKeys: ERROR_TEXT_KEYS };
|
|
1431
|
+
}
|
|
1432
|
+
return rules.exemptKeys === void 0 && rules.headerKept !== true ? rules : { ...rules, exemptKeys: void 0, headerKept: void 0 };
|
|
1433
|
+
}
|
|
1434
|
+
function isCensored(rules, key, value) {
|
|
1435
|
+
return matchesKey(rules.sensitive, key) && !(typeof value === "string" && rules.exemptKeys?.has(key));
|
|
1436
|
+
}
|
|
1437
|
+
function messageCensor(rules) {
|
|
1438
|
+
return (text) => rules.sensitive.has("message") ? rules.censor : text;
|
|
1439
|
+
}
|
|
1440
|
+
var isStackKey = (key) => matchesKey(STACK_NAMES, key);
|
|
1441
|
+
var STACK_NAMES = capturedSet(["stack"]);
|
|
1442
|
+
var MESSAGE_NAMES = capturedSet(["message"]);
|
|
1443
|
+
var MAX_STACK_ALIASES = 8;
|
|
1444
|
+
var NO_STACK = { texts: /* @__PURE__ */ new Map(), stackKeys: capturedSet(), overflow: false };
|
|
1445
|
+
function headerMessage(rules, source, keys, isError2) {
|
|
1446
|
+
const keysOf = (names) => keys.filter((candidate) => matchesKey(names, candidate));
|
|
1447
|
+
const stacks = keysOf(STACK_NAMES);
|
|
1448
|
+
if (stacks.length === 0) return isError2 ? void 0 : NO_STACK;
|
|
1449
|
+
const hides = rules.sensitive.has("message") && (isError2 || rules.exemptKeys?.has("message") !== true && rules.headerKept !== true);
|
|
1450
|
+
const texts = /* @__PURE__ */ new Map();
|
|
1451
|
+
if (hides) {
|
|
1452
|
+
for (const key of keysOf(MESSAGE_NAMES)) {
|
|
1453
|
+
const text = Reflect.get(source, key);
|
|
1454
|
+
if (typeof text === "string") texts.set(key, text);
|
|
1455
|
+
}
|
|
1456
|
+
const named = keys.includes("message") ? void 0 : Reflect.get(source, "message");
|
|
1457
|
+
if (typeof named === "string") texts.set("message", named);
|
|
1458
|
+
}
|
|
1459
|
+
const overflow = stacks.length > MAX_STACK_ALIASES || capturedSet(texts.values()).size > MAX_STACK_ALIASES || [...texts.values()].some((text) => text.length > MAX_TEXT_LENGTH);
|
|
1460
|
+
return { texts, stackKeys: capturedSet(stacks), overflow };
|
|
1461
|
+
}
|
|
1462
|
+
function readField(source, key, header) {
|
|
1463
|
+
return header?.texts.get(key) ?? Reflect.get(source, key);
|
|
1464
|
+
}
|
|
1465
|
+
function censorAnyName(rules, name) {
|
|
1466
|
+
if (typeof name === "string") return censorName(name, messageCensor(rules));
|
|
1467
|
+
const holder = typeof name === "object" && name !== null || typeof name === "function";
|
|
1468
|
+
return holder && rules.sensitive.has("message") ? rules.censor : name;
|
|
1469
|
+
}
|
|
1470
|
+
function scrubPlainStack(rules, stack, header) {
|
|
1471
|
+
const texts = [...capturedSet(header?.texts.values())];
|
|
1472
|
+
const longest = texts.reduce((most, text) => Math.max(most, text.length), 0);
|
|
1473
|
+
const hidden = hideMessagesInStack(
|
|
1474
|
+
stack.slice(0, MAX_STACK_SCAN + longest),
|
|
1475
|
+
texts,
|
|
1476
|
+
rules.censor,
|
|
1477
|
+
MAX_STACK_SCAN
|
|
1478
|
+
);
|
|
1479
|
+
return scrubStack(hidden, void 0, stack.length > MAX_STACK_SCAN);
|
|
1480
|
+
}
|
|
1481
|
+
function errorTextField(rules, key, value, isError2, header) {
|
|
1482
|
+
const isStack = typeof value === "string" && (header === void 0 ? !isError2 && matchesKey(STACK_NAMES, key) : header.stackKeys.has(key));
|
|
1483
|
+
if (isStack) {
|
|
1484
|
+
return header?.overflow === true ? rules.censor : scrubPlainStack(rules, value, header);
|
|
1485
|
+
}
|
|
1486
|
+
if (!isError2 || !ERROR_TEXT_FIELDS.has(key)) return value;
|
|
1487
|
+
const cut = cutIfText(value);
|
|
1488
|
+
return key === "name" ? censorAnyName(rules, cut) : cut;
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
// src/server/utils/is-plain-record.util.ts
|
|
1492
|
+
function isPlainRecord(node) {
|
|
1493
|
+
try {
|
|
1494
|
+
const prototype = Object.getPrototypeOf(node);
|
|
1495
|
+
return prototype === Object.prototype || prototype === null;
|
|
1496
|
+
} catch {
|
|
1497
|
+
return false;
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1011
1501
|
// src/server/services/pino-logger.service.ts
|
|
1012
1502
|
var OWNED_PAYLOAD_KEYS = ["logKey", "userId", "context"];
|
|
1013
1503
|
var ENTRY_STRUCTURE_KEYS = ["level", "time", "msg", "service", "deployment"];
|
|
@@ -1018,17 +1508,17 @@ var RESOURCE_KEYS = [
|
|
|
1018
1508
|
"service.instance.id",
|
|
1019
1509
|
"deployment.environment.name"
|
|
1020
1510
|
];
|
|
1021
|
-
var OWNED_KEY_SPELLINGS =
|
|
1511
|
+
var OWNED_KEY_SPELLINGS = capturedSet(
|
|
1022
1512
|
[...OWNED_PAYLOAD_KEYS, ...ENTRY_STRUCTURE_KEYS, ...RESOURCE_KEYS].map((key) => foldKey(key))
|
|
1023
1513
|
);
|
|
1024
|
-
var DERIVED_KEYS =
|
|
1514
|
+
var DERIVED_KEYS = capturedSet([
|
|
1025
1515
|
"exception.type",
|
|
1026
1516
|
"exception.message",
|
|
1027
1517
|
"exception.stacktrace",
|
|
1028
1518
|
"error.type"
|
|
1029
1519
|
]);
|
|
1030
1520
|
var isOwnedKey = (key) => {
|
|
1031
|
-
const lower = key
|
|
1521
|
+
const lower = lowerCase(key);
|
|
1032
1522
|
return OWNED_KEY_SPELLINGS.has(foldKey(key)) || DERIVED_KEYS.has(foldKey(key, true)) || lower.startsWith("service.") || lower.startsWith("deployment.");
|
|
1033
1523
|
};
|
|
1034
1524
|
function withoutOwnedKeys(metadata, omit) {
|
|
@@ -1067,12 +1557,27 @@ function objectMessageText(fields) {
|
|
|
1067
1557
|
}
|
|
1068
1558
|
return void 0;
|
|
1069
1559
|
}
|
|
1070
|
-
function hideStackMessage(payload, text, censor) {
|
|
1071
|
-
const
|
|
1072
|
-
if (text?.key !== "message"
|
|
1560
|
+
function hideStackMessage(payload, text, censor, positional) {
|
|
1561
|
+
const kept = positional === void 0 ? void 0 : cutText(positional);
|
|
1562
|
+
if (text?.key !== "message") return kept;
|
|
1073
1563
|
const censored = censor(text.text);
|
|
1074
|
-
if (censored === text.text) return;
|
|
1075
|
-
|
|
1564
|
+
if (censored === text.text) return kept;
|
|
1565
|
+
const keys = Object.keys(payload).filter(isStackKey);
|
|
1566
|
+
const overflow = keys.length + (positional === void 0 ? 0 : 1) > MAX_STACK_ALIASES || text.text.length > MAX_TEXT_LENGTH;
|
|
1567
|
+
const hide = (stack) => overflow ? censored : cutText(
|
|
1568
|
+
hideMessagesInStack(
|
|
1569
|
+
stack.slice(0, MAX_TEXT_LENGTH + text.text.length),
|
|
1570
|
+
[text.text],
|
|
1571
|
+
censored,
|
|
1572
|
+
MAX_TEXT_LENGTH
|
|
1573
|
+
),
|
|
1574
|
+
stack.length > MAX_TEXT_LENGTH
|
|
1575
|
+
);
|
|
1576
|
+
for (const key of keys) {
|
|
1577
|
+
const stack = Reflect.get(payload, key);
|
|
1578
|
+
if (typeof stack === "string") Reflect.set(payload, key, hide(stack));
|
|
1579
|
+
}
|
|
1580
|
+
return positional === void 0 ? void 0 : hide(positional);
|
|
1076
1581
|
}
|
|
1077
1582
|
function readObjectMessage(message) {
|
|
1078
1583
|
const fields = isPlainRecord(message) && !isErrorLike(message) ? message : void 0;
|
|
@@ -1093,9 +1598,12 @@ function findErrorParam(optionalParams) {
|
|
|
1093
1598
|
}
|
|
1094
1599
|
function assignIfDefined(payload, key, value) {
|
|
1095
1600
|
if (value !== void 0) {
|
|
1096
|
-
Reflect.defineProperty(payload, key, { value, enumerable: true });
|
|
1601
|
+
Reflect.defineProperty(payload, key, bareDescriptor({ value, enumerable: true }));
|
|
1097
1602
|
}
|
|
1098
1603
|
}
|
|
1604
|
+
function emitRecord(pino2, level, payload, msg) {
|
|
1605
|
+
if (pinoBuiltinsIntact()) pino2[level](payload, msg);
|
|
1606
|
+
}
|
|
1099
1607
|
var PinoLoggerService = class {
|
|
1100
1608
|
/**
|
|
1101
1609
|
* **A hand-built instance is NOT this library's behaviour.** Constructing
|
|
@@ -1150,17 +1658,27 @@ var PinoLoggerService = class {
|
|
|
1150
1658
|
if (isErrorLike(message)) {
|
|
1151
1659
|
const payload2 = { err: message };
|
|
1152
1660
|
assignIfDefined(payload2, "context", this.resolveContext(optionalParams));
|
|
1153
|
-
this.pino
|
|
1661
|
+
emitRecord(this.pino, "error", payload2, this.errorText(message));
|
|
1154
1662
|
return;
|
|
1155
1663
|
}
|
|
1156
1664
|
const stack = typeof optionalParams[0] === "string" ? optionalParams[0] : void 0;
|
|
1157
1665
|
const context = typeof optionalParams[1] === "string" ? optionalParams[1] : this.context;
|
|
1158
1666
|
const { fields, text, payload } = readObjectMessage(message);
|
|
1159
|
-
|
|
1667
|
+
const positional = hideStackMessage(
|
|
1668
|
+
payload,
|
|
1669
|
+
text,
|
|
1670
|
+
(message2) => this.censorText({ key: "message", text: message2 }),
|
|
1671
|
+
stack
|
|
1672
|
+
);
|
|
1160
1673
|
assignIfDefined(payload, "context", context);
|
|
1161
|
-
assignIfDefined(payload, "stack",
|
|
1674
|
+
assignIfDefined(payload, "stack", positional);
|
|
1162
1675
|
assignIfDefined(payload, "err", findErrorParam(optionalParams));
|
|
1163
|
-
|
|
1676
|
+
emitRecord(
|
|
1677
|
+
this.pino,
|
|
1678
|
+
"error",
|
|
1679
|
+
payload,
|
|
1680
|
+
this.nestStyleMessage("error", void 0, fields, text, message)
|
|
1681
|
+
);
|
|
1164
1682
|
}
|
|
1165
1683
|
/**
|
|
1166
1684
|
* NestJS `warn` (warn level).
|
|
@@ -1246,7 +1764,7 @@ var PinoLoggerService = class {
|
|
|
1246
1764
|
};
|
|
1247
1765
|
assignIfDefined(payload, "userId", userId);
|
|
1248
1766
|
assignIfDefined(payload, "context", this.context);
|
|
1249
|
-
this.pino
|
|
1767
|
+
emitRecord(this.pino, "error", payload, this.errorText(error));
|
|
1250
1768
|
}
|
|
1251
1769
|
// ─── Helpers / escape hatches ─────────────────────────────────────────────
|
|
1252
1770
|
/**
|
|
@@ -1306,9 +1824,9 @@ var PinoLoggerService = class {
|
|
|
1306
1824
|
assignIfDefined(payload, "context", this.context);
|
|
1307
1825
|
const line = toBoundedMessage(message);
|
|
1308
1826
|
if (level === "info") {
|
|
1309
|
-
this.pino
|
|
1827
|
+
emitRecord(this.pino, "info", payload, line);
|
|
1310
1828
|
} else {
|
|
1311
|
-
this.pino
|
|
1829
|
+
emitRecord(this.pino, "warn", payload, line);
|
|
1312
1830
|
}
|
|
1313
1831
|
}
|
|
1314
1832
|
/** Emit a NestJS-style variadic log, dispatching by level without computed indexing. */
|
|
@@ -1364,23 +1882,7 @@ var PinoLoggerService = class {
|
|
|
1364
1882
|
const leading = isErrorLike(message) ? message : void 0;
|
|
1365
1883
|
assignIfDefined(payload, "err", leading ?? findErrorParam(optionalParams));
|
|
1366
1884
|
const msg = this.nestStyleMessage(level, leading, fields, text, message);
|
|
1367
|
-
|
|
1368
|
-
case "info":
|
|
1369
|
-
this.pino.info(payload, msg);
|
|
1370
|
-
break;
|
|
1371
|
-
case "warn":
|
|
1372
|
-
this.pino.warn(payload, msg);
|
|
1373
|
-
break;
|
|
1374
|
-
case "debug":
|
|
1375
|
-
this.pino.debug(payload, msg);
|
|
1376
|
-
break;
|
|
1377
|
-
case "trace":
|
|
1378
|
-
this.pino.trace(payload, msg);
|
|
1379
|
-
break;
|
|
1380
|
-
case "fatal":
|
|
1381
|
-
this.pino.fatal(payload, msg);
|
|
1382
|
-
break;
|
|
1383
|
-
}
|
|
1885
|
+
emitRecord(this.pino, level, payload, msg);
|
|
1384
1886
|
}
|
|
1385
1887
|
};
|
|
1386
1888
|
PinoLoggerService = __decorateClass([
|
|
@@ -1574,6 +2076,7 @@ var NANOID_REGEX = /\/[A-Za-z0-9_-]{21}(?![A-Za-z0-9_-])/g;
|
|
|
1574
2076
|
var NUMERIC_ID_REGEX = /\/\d+/g;
|
|
1575
2077
|
var ID_PLACEHOLDER = "/:id";
|
|
1576
2078
|
var SECRET_PLACEHOLDER = ":redacted";
|
|
2079
|
+
var WHOLE_PATH_PLACEHOLDER = `/${SECRET_PLACEHOLDER}`;
|
|
1577
2080
|
var HEX_SECRET_REGEX = /^[0-9a-f]{32,}$/i;
|
|
1578
2081
|
var JWT_SECRET_REGEX = /^eyJ[\w-]*\.[\w-]+\.[\w-]*$/;
|
|
1579
2082
|
var TOKEN_SECRET_REGEX = /^[A-Za-z0-9_+/-]{32,}={0,2}$/;
|
|
@@ -1605,6 +2108,7 @@ function looksLikeToken(value) {
|
|
|
1605
2108
|
return HEX_SECRET_REGEX.test(value) || HEX_RUN_REGEX.test(value) || JWT_SECRET_REGEX.test(value) || TOKEN_SECRET_REGEX.test(value) && !SLUG_REGEX.test(value) && !UUID_SEGMENT_REGEX.test(value);
|
|
1606
2109
|
}
|
|
1607
2110
|
function secretPathSegments(url, extra = []) {
|
|
2111
|
+
if (!pinoBuiltinsIntact()) return [url];
|
|
1608
2112
|
const found = /* @__PURE__ */ new Set();
|
|
1609
2113
|
for (const segment of stripQueryString(url).split("/")) {
|
|
1610
2114
|
if (isSecretSegment(segment, extra)) found.add(segment);
|
|
@@ -1612,6 +2116,7 @@ function secretPathSegments(url, extra = []) {
|
|
|
1612
2116
|
return [...found];
|
|
1613
2117
|
}
|
|
1614
2118
|
function scrubSecretSegments(path2, extra = []) {
|
|
2119
|
+
if (!pinoBuiltinsIntact()) return WHOLE_PATH_PLACEHOLDER;
|
|
1615
2120
|
return path2.split("/").map((segment) => isSecretSegment(segment, extra) ? SECRET_PLACEHOLDER : segment).join("/");
|
|
1616
2121
|
}
|
|
1617
2122
|
function normalizeUrl(url, extra = []) {
|
|
@@ -1622,6 +2127,7 @@ function stripQueryString(url) {
|
|
|
1622
2127
|
return queryStart === -1 ? url : url.slice(0, queryStart);
|
|
1623
2128
|
}
|
|
1624
2129
|
function withoutRequestSecrets(text, extra, ...urls) {
|
|
2130
|
+
if (!pinoBuiltinsIntact()) return SECRET_PLACEHOLDER;
|
|
1625
2131
|
let result = text;
|
|
1626
2132
|
const segments = /* @__PURE__ */ new Set();
|
|
1627
2133
|
for (const url of urls) {
|
|
@@ -2121,13 +2627,128 @@ var LogContextService = class {
|
|
|
2121
2627
|
LogContextService = __decorateClass([
|
|
2122
2628
|
Injectable()
|
|
2123
2629
|
], LogContextService);
|
|
2630
|
+
var IntrinsicPromise = Object.getPrototypeOf((async () => void 0)()).constructor;
|
|
2631
|
+
var hasOwn = Object.hasOwn;
|
|
2632
|
+
var isNativePromise = types.isPromise;
|
|
2633
|
+
var define = Object.defineProperty;
|
|
2634
|
+
var remove = Reflect.deleteProperty;
|
|
2635
|
+
var ownDescriptor = Reflect.getOwnPropertyDescriptor;
|
|
2636
|
+
var nativeThen = Function.prototype.call.bind(IntrinsicPromise.prototype.then);
|
|
2637
|
+
var promisePrototype = IntrinsicPromise.prototype;
|
|
2638
|
+
var speciesGetter = ownSpeciesGetter();
|
|
2639
|
+
var objectRoot = Object.prototype;
|
|
2640
|
+
var arrayRoot = Array.prototype;
|
|
2641
|
+
var functionRoot = Function.prototype;
|
|
2642
|
+
function ownSpeciesGetter() {
|
|
2643
|
+
const descriptor = ownDescriptor(IntrinsicPromise, Symbol.species);
|
|
2644
|
+
return descriptor !== void 0 && hasOwn(descriptor, "get") ? descriptor.get : void 0;
|
|
2645
|
+
}
|
|
2646
|
+
var PromiseTamperedError = class extends Error {
|
|
2647
|
+
constructor() {
|
|
2648
|
+
super(
|
|
2649
|
+
"the promise baseline does not hold: the constructor of the promise prototype was replaced, a then was planted on a prototype root, or the promise awaited carries its own constructor or then"
|
|
2650
|
+
);
|
|
2651
|
+
}
|
|
2652
|
+
};
|
|
2653
|
+
if (speciesGetter === void 0) throw new PromiseTamperedError();
|
|
2654
|
+
function promiseIntact() {
|
|
2655
|
+
const own = ownDescriptor(promisePrototype, "constructor");
|
|
2656
|
+
if (own === void 0 || !hasOwn(own, "value") || own.value !== IntrinsicPromise) return false;
|
|
2657
|
+
if (ownSpeciesGetter() !== speciesGetter) return false;
|
|
2658
|
+
return !hasOwn(objectRoot, "then") && !hasOwn(arrayRoot, "then") && !hasOwn(functionRoot, "then");
|
|
2659
|
+
}
|
|
2660
|
+
function intactOr(pending) {
|
|
2661
|
+
if (!promiseIntact()) throw new PromiseTamperedError();
|
|
2662
|
+
return pending;
|
|
2663
|
+
}
|
|
2664
|
+
function absorb(pending) {
|
|
2665
|
+
const drop = () => void 0;
|
|
2666
|
+
const pinned = pin(pending);
|
|
2667
|
+
try {
|
|
2668
|
+
try {
|
|
2669
|
+
nativeThen(pending, drop, drop);
|
|
2670
|
+
return;
|
|
2671
|
+
} catch {
|
|
2672
|
+
}
|
|
2673
|
+
void (async () => {
|
|
2674
|
+
try {
|
|
2675
|
+
await pending;
|
|
2676
|
+
} catch {
|
|
2677
|
+
}
|
|
2678
|
+
})();
|
|
2679
|
+
} finally {
|
|
2680
|
+
if (pinned) unpin(pending);
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2683
|
+
function tag(promise) {
|
|
2684
|
+
setOwnConstructor(promise, false);
|
|
2685
|
+
return promise;
|
|
2686
|
+
}
|
|
2687
|
+
function setOwnConstructor(target, temporary) {
|
|
2688
|
+
try {
|
|
2689
|
+
define(target, "constructor", {
|
|
2690
|
+
__proto__: null,
|
|
2691
|
+
value: IntrinsicPromise,
|
|
2692
|
+
writable: temporary,
|
|
2693
|
+
configurable: temporary
|
|
2694
|
+
});
|
|
2695
|
+
return true;
|
|
2696
|
+
} catch {
|
|
2697
|
+
return false;
|
|
2698
|
+
}
|
|
2699
|
+
}
|
|
2700
|
+
function pin(target) {
|
|
2701
|
+
if (!isNativePromise(target) || hasOwn(target, "constructor")) return false;
|
|
2702
|
+
return setOwnConstructor(target, true);
|
|
2703
|
+
}
|
|
2704
|
+
function unpin(target) {
|
|
2705
|
+
try {
|
|
2706
|
+
remove(target, "constructor");
|
|
2707
|
+
} catch {
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2710
|
+
function hold(value) {
|
|
2711
|
+
if (!isNativePromise(value)) return value;
|
|
2712
|
+
if (hasOwn(value, "constructor") || hasOwn(value, "then") || !setOwnConstructor(value, true)) {
|
|
2713
|
+
throw new PromiseTamperedError();
|
|
2714
|
+
}
|
|
2715
|
+
try {
|
|
2716
|
+
return (async () => {
|
|
2717
|
+
await value;
|
|
2718
|
+
})();
|
|
2719
|
+
} finally {
|
|
2720
|
+
unpin(value);
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
function awaitOutcome(work, finish, held) {
|
|
2724
|
+
absorb(run(work, finish, held));
|
|
2725
|
+
}
|
|
2726
|
+
async function run(work, finish, held) {
|
|
2727
|
+
if (!promiseIntact()) {
|
|
2728
|
+
absorb(held);
|
|
2729
|
+
return finish({ __proto__: null, ok: false, cause: new PromiseTamperedError() });
|
|
2730
|
+
}
|
|
2731
|
+
let pending;
|
|
2732
|
+
try {
|
|
2733
|
+
pending = work();
|
|
2734
|
+
} catch (cause) {
|
|
2735
|
+
return finish({ __proto__: null, ok: false, cause });
|
|
2736
|
+
}
|
|
2737
|
+
try {
|
|
2738
|
+
await hold(intactOr(pending));
|
|
2739
|
+
} catch (cause) {
|
|
2740
|
+
if (cause instanceof PromiseTamperedError) absorb(pending);
|
|
2741
|
+
return finish({ __proto__: null, ok: false, cause });
|
|
2742
|
+
}
|
|
2743
|
+
finish({ __proto__: null, ok: true, cause: void 0 });
|
|
2744
|
+
}
|
|
2124
2745
|
|
|
2125
2746
|
// src/server/middlewares/request-id.middleware.ts
|
|
2126
2747
|
var REQUEST_ID_HEADER = "x-request-id";
|
|
2127
2748
|
var MAX_CORRELATION_ID_LENGTH = 256;
|
|
2128
2749
|
var CORRELATION_ID_CHARSET = /^[A-Za-z0-9._:/+=-]+$/;
|
|
2129
2750
|
function settleLate(answer) {
|
|
2130
|
-
|
|
2751
|
+
absorb(answer);
|
|
2131
2752
|
}
|
|
2132
2753
|
var INHERITABLE_CONTEXT_KEYS = ["requestId", "tenantId"];
|
|
2133
2754
|
function isAcceptableHeaderValue(value) {
|
|
@@ -2585,7 +3206,7 @@ function createTraceContextMixin(logContext, opts) {
|
|
|
2585
3206
|
// src/server/utils/compile-redact-paths.util.ts
|
|
2586
3207
|
function compileRedactPaths(extraPaths, shouldSkipDefaults) {
|
|
2587
3208
|
const sources = shouldSkipDefaults ? [extraPaths] : [DEFAULT_REDACT_PATHS, extraPaths];
|
|
2588
|
-
return Array.from(
|
|
3209
|
+
return Array.from(capturedSet(sources.flat()));
|
|
2589
3210
|
}
|
|
2590
3211
|
|
|
2591
3212
|
// src/server/utils/cut-strings.util.ts
|
|
@@ -2733,15 +3354,14 @@ function destinationToStream(destination, health, maxQueueBytes = 0, censorMessa
|
|
|
2733
3354
|
callback();
|
|
2734
3355
|
} else {
|
|
2735
3356
|
health.markWritePending(destination);
|
|
2736
|
-
|
|
2737
|
-
() =>
|
|
3357
|
+
awaitOutcome(
|
|
3358
|
+
() => result,
|
|
3359
|
+
(outcome) => {
|
|
2738
3360
|
health.markWriteSettled(destination);
|
|
2739
|
-
callback();
|
|
3361
|
+
if (outcome.ok) callback();
|
|
3362
|
+
else onFailure(outcome.cause);
|
|
2740
3363
|
},
|
|
2741
|
-
|
|
2742
|
-
health.markWriteSettled(destination);
|
|
2743
|
-
onFailure(cause);
|
|
2744
|
-
}
|
|
3364
|
+
result
|
|
2745
3365
|
);
|
|
2746
3366
|
}
|
|
2747
3367
|
} catch (cause) {
|
|
@@ -2760,11 +3380,11 @@ function mergeMixinSafely(mergeObject, mixinObject) {
|
|
|
2760
3380
|
const merged = {};
|
|
2761
3381
|
const written = /* @__PURE__ */ new Set();
|
|
2762
3382
|
for (const [key, value] of Object.entries(mixinObject)) {
|
|
2763
|
-
if (value !== void 0) written
|
|
3383
|
+
if (value !== void 0) setAdd(written, foldKey(key));
|
|
2764
3384
|
}
|
|
2765
3385
|
for (const key of Object.keys(mergeObject)) {
|
|
2766
3386
|
if (key === PROTOTYPE_KEY) continue;
|
|
2767
|
-
if (key !== EXPLICIT_USER_KEY && written
|
|
3387
|
+
if (key !== EXPLICIT_USER_KEY && setHas(written, foldKey(key))) continue;
|
|
2768
3388
|
Reflect.set(merged, key, Reflect.get(mergeObject, key));
|
|
2769
3389
|
}
|
|
2770
3390
|
for (const [key, value] of Object.entries(mixinObject)) {
|
|
@@ -2786,206 +3406,83 @@ function mergeMixinSafely(mergeObject, mixinObject) {
|
|
|
2786
3406
|
function censorRawHeaders(raw, sensitive, censor) {
|
|
2787
3407
|
return raw.map((entry, index) => {
|
|
2788
3408
|
const name = index % 2 === 1 ? raw[index - 1] : void 0;
|
|
2789
|
-
return typeof name === "string" && sensitive
|
|
3409
|
+
return typeof name === "string" && matchesKey(sensitive, name) ? censor : entry;
|
|
2790
3410
|
});
|
|
2791
3411
|
}
|
|
2792
3412
|
|
|
2793
|
-
// src/server/utils/redact-error-parts.util.ts
|
|
2794
|
-
function defineOwn(target, key, value) {
|
|
2795
|
-
Reflect.defineProperty(target, key, { value, enumerable: true, writable: true });
|
|
2796
|
-
}
|
|
2797
|
-
var linkDepths = /* @__PURE__ */ new WeakMap();
|
|
2798
|
-
var ERROR_TEXT_FIELDS = /* @__PURE__ */ new Set(["name", "message", "stack"]);
|
|
2799
|
-
var INCOMPLETE_KEY = "_errorFieldsIncomplete";
|
|
2800
|
-
var widthMarkers = /* @__PURE__ */ new WeakSet();
|
|
2801
|
-
function capErrors(errors, host) {
|
|
2802
|
-
if (!Array.isArray(errors) || errors.length <= MAX_AGGREGATE_ERRORS) return errors;
|
|
2803
|
-
if (host.hasToJson(errors)) return errors;
|
|
2804
|
-
const kept = [];
|
|
2805
|
-
for (let index = 0; index < MAX_AGGREGATE_ERRORS; index++) kept.push(Reflect.get(errors, index));
|
|
2806
|
-
const marker = createWidthMarker(errors.length - MAX_AGGREGATE_ERRORS);
|
|
2807
|
-
widthMarkers.add(marker);
|
|
2808
|
-
kept.push(marker);
|
|
2809
|
-
return kept;
|
|
2810
|
-
}
|
|
2811
|
-
function linkTargets(value) {
|
|
2812
|
-
const targets = [];
|
|
2813
|
-
const take = (link) => {
|
|
2814
|
-
if (typeof link === "object" && link !== null) targets.push(link);
|
|
2815
|
-
};
|
|
2816
|
-
if (!Array.isArray(value)) take(value);
|
|
2817
|
-
else for (let index = 0; index < value.length; index++) take(Reflect.get(value, index));
|
|
2818
|
-
return targets;
|
|
2819
|
-
}
|
|
2820
|
-
function walkChainPart(value, level, host, depth2) {
|
|
2821
|
-
const targets = linkTargets(value);
|
|
2822
|
-
if (targets.length > 0 && level + 1 > DEFAULT_MAX_CAUSE_DEPTH) {
|
|
2823
|
-
if (Array.isArray(value) && host.nameKey === "name") {
|
|
2824
|
-
return Array.from({ length: value.length }, (_member, index) => {
|
|
2825
|
-
const member = Reflect.get(value, index);
|
|
2826
|
-
return typeof member === "object" && member !== null && widthMarkers.has(member) ? member : createDepthMarker();
|
|
2827
|
-
});
|
|
2828
|
-
}
|
|
2829
|
-
return createDepthMarker();
|
|
2830
|
-
}
|
|
2831
|
-
const before = new Map(targets.map((target) => [target, linkDepths.get(target)]));
|
|
2832
|
-
for (const target of targets) linkDepths.set(target, level + 1);
|
|
2833
|
-
try {
|
|
2834
|
-
return host.walk(value, depth2 + 1);
|
|
2835
|
-
} finally {
|
|
2836
|
-
before.forEach((earlier, target) => {
|
|
2837
|
-
if (earlier === void 0) linkDepths.delete(target);
|
|
2838
|
-
else linkDepths.set(target, earlier);
|
|
2839
|
-
});
|
|
2840
|
-
}
|
|
2841
|
-
}
|
|
2842
|
-
function cutOrWalk(value, level, host, depth2) {
|
|
2843
|
-
return typeof value === "string" ? cutText(value) : walkChainPart(value, level, host, depth2);
|
|
2844
|
-
}
|
|
2845
|
-
function writeName(value, level, host, depth2) {
|
|
2846
|
-
const censored = host.censorName(typeof value === "string" ? cutText(value) : value);
|
|
2847
|
-
return censored === value ? cutOrWalk(value, level, host, depth2) : censored;
|
|
2848
|
-
}
|
|
2849
|
-
function addErrorParts(copy, error, ownKeys, host, depth2) {
|
|
2850
|
-
const taken = new Set(ownKeys);
|
|
2851
|
-
const level = linkDepths.get(error) ?? 0;
|
|
2852
|
-
let incomplete = false;
|
|
2853
|
-
const add = (key, covers, read, write = (value) => walkChainPart(value, level, host, depth2)) => {
|
|
2854
|
-
if (taken.has(key)) return;
|
|
2855
|
-
try {
|
|
2856
|
-
const written = write(read());
|
|
2857
|
-
if (written === void 0) return;
|
|
2858
|
-
const covered = covers.some((name) => host.sensitive.has(name));
|
|
2859
|
-
defineOwn(copy, key, covered ? host.censor : written);
|
|
2860
|
-
} catch {
|
|
2861
|
-
incomplete = true;
|
|
2862
|
-
}
|
|
2863
|
-
};
|
|
2864
|
-
add(
|
|
2865
|
-
host.nameKey,
|
|
2866
|
-
[host.nameKey, "name"],
|
|
2867
|
-
() => error.name,
|
|
2868
|
-
(name) => writeName(name, level, host, depth2)
|
|
2869
|
-
);
|
|
2870
|
-
add(
|
|
2871
|
-
"message",
|
|
2872
|
-
["message"],
|
|
2873
|
-
() => error.message,
|
|
2874
|
-
(message) => cutOrWalk(message, level, host, depth2)
|
|
2875
|
-
);
|
|
2876
|
-
add(
|
|
2877
|
-
"stack",
|
|
2878
|
-
["stack", "name", "message"],
|
|
2879
|
-
() => error.stack,
|
|
2880
|
-
(stack) => typeof stack === "string" ? scrubStack(stack) : void 0
|
|
2881
|
-
);
|
|
2882
|
-
add("cause", ["cause"], () => error.cause);
|
|
2883
|
-
add("errors", ["errors"], () => capErrors(error.errors, host));
|
|
2884
|
-
if (incomplete && !taken.has(INCOMPLETE_KEY)) defineOwn(copy, INCOMPLETE_KEY, true);
|
|
2885
|
-
}
|
|
2886
|
-
|
|
2887
|
-
// src/server/utils/error-text-exemption.util.ts
|
|
2888
|
-
var ERROR_TEXT_KEYS = /* @__PURE__ */ new Set(["message"]);
|
|
2889
|
-
function leavesErrorText(rules, key, value, honorToJson) {
|
|
2890
|
-
return rules.errorTextToSerializer && !honorToJson && key === "err" && !Array.isArray(value);
|
|
2891
|
-
}
|
|
2892
|
-
function rulesBelow(rules, key, value, honorToJson) {
|
|
2893
|
-
if (leavesErrorText(rules, key, value, honorToJson)) {
|
|
2894
|
-
return { ...rules, exemptKeys: ERROR_TEXT_KEYS };
|
|
2895
|
-
}
|
|
2896
|
-
return rules.exemptKeys === void 0 && rules.headerKept !== true ? rules : { ...rules, exemptKeys: void 0, headerKept: void 0 };
|
|
2897
|
-
}
|
|
2898
|
-
function isCensored(rules, key, value) {
|
|
2899
|
-
const lower = key.toLowerCase();
|
|
2900
|
-
return rules.sensitive.has(lower) && !(typeof value === "string" && rules.exemptKeys?.has(lower));
|
|
2901
|
-
}
|
|
2902
|
-
function messageCensor(rules) {
|
|
2903
|
-
return (text) => rules.sensitive.has("message") ? rules.censor : text;
|
|
2904
|
-
}
|
|
2905
|
-
function headerMessage(rules, source, keys, isError2) {
|
|
2906
|
-
if (isError2 || !rules.sensitive.has("message") || rules.exemptKeys?.has("message") === true)
|
|
2907
|
-
return void 0;
|
|
2908
|
-
if (rules.headerKept === true) return void 0;
|
|
2909
|
-
const key = keys.find((candidate) => foldKey(candidate) === "message");
|
|
2910
|
-
if (key === void 0 || !keys.some((candidate) => foldKey(candidate) === "stack")) {
|
|
2911
|
-
return void 0;
|
|
2912
|
-
}
|
|
2913
|
-
const text = Reflect.get(source, key);
|
|
2914
|
-
return typeof text === "string" ? { key, text } : void 0;
|
|
2915
|
-
}
|
|
2916
|
-
function readField(source, key, header) {
|
|
2917
|
-
return header !== void 0 && key === header.key ? header.text : Reflect.get(source, key);
|
|
2918
|
-
}
|
|
2919
|
-
function censorAnyName(rules, name) {
|
|
2920
|
-
if (typeof name === "string") return censorName(name, messageCensor(rules));
|
|
2921
|
-
const holder = typeof name === "object" && name !== null || typeof name === "function";
|
|
2922
|
-
return holder && rules.sensitive.has("message") ? rules.censor : name;
|
|
2923
|
-
}
|
|
2924
|
-
function errorTextField(rules, key, value, isError2, header) {
|
|
2925
|
-
if (header !== void 0 && foldKey(key) === "stack" && typeof value === "string") {
|
|
2926
|
-
return hideMessageInStack(value, header.text, rules.censor);
|
|
2927
|
-
}
|
|
2928
|
-
if (!isError2 || !ERROR_TEXT_FIELDS.has(key)) return value;
|
|
2929
|
-
const cut = cutIfText(value);
|
|
2930
|
-
return key === "name" ? censorAnyName(rules, cut) : cut;
|
|
2931
|
-
}
|
|
2932
|
-
|
|
2933
3413
|
// src/server/utils/redact-error-clone.util.ts
|
|
2934
3414
|
function shadowHook(target) {
|
|
2935
|
-
Reflect.defineProperty(target, "toJSON", { value: void 0, configurable: true });
|
|
3415
|
+
Reflect.defineProperty(target, "toJSON", bareDescriptor({ value: void 0, configurable: true }));
|
|
2936
3416
|
}
|
|
2937
3417
|
function withoutEnumerableKeys(clone) {
|
|
2938
3418
|
for (const key of Object.keys(clone)) Reflect.deleteProperty(clone, key);
|
|
2939
3419
|
}
|
|
2940
3420
|
function discardWrite() {
|
|
2941
3421
|
}
|
|
2942
|
-
function
|
|
2943
|
-
const
|
|
2944
|
-
for (const
|
|
3422
|
+
function relaxedDescriptors(descriptors) {
|
|
3423
|
+
const relaxed = /* @__PURE__ */ Object.create(null);
|
|
3424
|
+
for (const key of Reflect.ownKeys(descriptors)) {
|
|
3425
|
+
const descriptor = bareDescriptor(Reflect.get(descriptors, key));
|
|
2945
3426
|
descriptor.configurable = true;
|
|
2946
|
-
if ("value"
|
|
3427
|
+
if (Object.hasOwn(descriptor, "value")) descriptor.writable = true;
|
|
2947
3428
|
else descriptor.set ??= discardWrite;
|
|
3429
|
+
Reflect.set(relaxed, key, descriptor);
|
|
2948
3430
|
}
|
|
2949
|
-
|
|
3431
|
+
return relaxed;
|
|
3432
|
+
}
|
|
3433
|
+
function cloneError(error) {
|
|
3434
|
+
const clone = Object.create(
|
|
3435
|
+
Object.getPrototypeOf(error),
|
|
3436
|
+
relaxedDescriptors(Object.getOwnPropertyDescriptors(error))
|
|
3437
|
+
);
|
|
2950
3438
|
const { stack } = error;
|
|
2951
3439
|
if (typeof stack === "string") {
|
|
2952
|
-
Reflect.defineProperty(
|
|
3440
|
+
Reflect.defineProperty(
|
|
3441
|
+
clone,
|
|
3442
|
+
"stack",
|
|
3443
|
+
bareDescriptor({ value: stack, enumerable: false, writable: true })
|
|
3444
|
+
);
|
|
2953
3445
|
}
|
|
2954
3446
|
withoutEnumerableKeys(clone);
|
|
2955
3447
|
shadowHook(clone);
|
|
2956
3448
|
return clone;
|
|
2957
3449
|
}
|
|
2958
|
-
|
|
2959
|
-
// src/server/utils/redact-by-name.util.ts
|
|
2960
|
-
var RAW_HEADER_KEYS = /* @__PURE__ */ new Set(["rawheaders", "rawtrailers"]);
|
|
2961
|
-
function censorHeaderArray(key, walked, rules) {
|
|
2962
|
-
return RAW_HEADER_KEYS.has(key.toLowerCase()) && Array.isArray(walked) ? censorRawHeaders(walked, rules.headerNames, rules.censor) : walked;
|
|
2963
|
-
}
|
|
2964
|
-
var REDACT_MAX_TRAVERSAL_DEPTH = 100;
|
|
2965
|
-
var REDACT_DEPTH_EXCEEDED = "[REDACTION_DEPTH_EXCEEDED]";
|
|
2966
|
-
var REDACT_MAX_VISITS = 2e5;
|
|
2967
|
-
var REDACT_BUDGET_EXCEEDED = "[REDACTION_BUDGET_EXCEEDED]";
|
|
2968
|
-
var REDACT_CIRCULAR = "[Circular]";
|
|
3450
|
+
var MAX_PROTOTYPE_HOPS2 = 256;
|
|
2969
3451
|
function resolveToJson(value, viaGet = false) {
|
|
2970
3452
|
let candidate = viaGet ? Reflect.get(value, "toJSON") : void 0;
|
|
2971
3453
|
let accessor = false;
|
|
2972
3454
|
let proxied = false;
|
|
2973
3455
|
let current = viaGet ? null : value;
|
|
2974
|
-
|
|
3456
|
+
for (let hops = 0; current !== null; hops++) {
|
|
3457
|
+
if (hops > MAX_PROTOTYPE_HOPS2) return { method: void 0, volatile: true, hostile: true };
|
|
2975
3458
|
proxied = proxied || types.isProxy(current);
|
|
2976
3459
|
const descriptor = Object.getOwnPropertyDescriptor(current, "toJSON");
|
|
2977
3460
|
if (descriptor !== void 0) {
|
|
2978
|
-
|
|
2979
|
-
|
|
3461
|
+
const getter = Object.hasOwn(descriptor, "get") ? descriptor.get : void 0;
|
|
3462
|
+
accessor = getter !== void 0;
|
|
3463
|
+
if (getter !== void 0) candidate = getter.call(value);
|
|
3464
|
+
else if (Object.hasOwn(descriptor, "value")) candidate = descriptor.value;
|
|
2980
3465
|
break;
|
|
2981
3466
|
}
|
|
2982
|
-
|
|
3467
|
+
const next = Object.getPrototypeOf(current);
|
|
3468
|
+
current = typeof next === "object" ? next : null;
|
|
2983
3469
|
}
|
|
2984
3470
|
return {
|
|
2985
3471
|
method: typeof candidate === "function" ? candidate : void 0,
|
|
2986
3472
|
volatile: accessor || proxied
|
|
2987
3473
|
};
|
|
2988
3474
|
}
|
|
3475
|
+
|
|
3476
|
+
// src/server/utils/redact-by-name.util.ts
|
|
3477
|
+
var RAW_HEADER_KEYS = capturedSet(["rawheaders", "rawtrailers"]);
|
|
3478
|
+
function censorHeaderArray(key, walked, rules) {
|
|
3479
|
+
return matchesKey(RAW_HEADER_KEYS, key) && Array.isArray(walked) ? censorRawHeaders(walked, rules.headerNames, rules.censor) : walked;
|
|
3480
|
+
}
|
|
3481
|
+
var REDACT_MAX_TRAVERSAL_DEPTH = 100;
|
|
3482
|
+
var REDACT_DEPTH_EXCEEDED = "[REDACTION_DEPTH_EXCEEDED]";
|
|
3483
|
+
var REDACT_MAX_VISITS = 2e5;
|
|
3484
|
+
var REDACT_BUDGET_EXCEEDED = "[REDACTION_BUDGET_EXCEEDED]";
|
|
3485
|
+
var REDACT_CIRCULAR = "[Circular]";
|
|
2989
3486
|
function rulesInside(rules, names, visits) {
|
|
2990
3487
|
return names === void 0 ? void 0 : { ...rules, sensitive: names, visits, insideErrors: void 0 };
|
|
2991
3488
|
}
|
|
@@ -3022,7 +3519,7 @@ function walk(value, rules, depth2, ancestors, honorToJson, inSerialized = false
|
|
|
3022
3519
|
if (++rules.visits.count > rules.maxVisits) {
|
|
3023
3520
|
return REDACT_BUDGET_EXCEEDED;
|
|
3024
3521
|
}
|
|
3025
|
-
if (ancestors
|
|
3522
|
+
if (setHas(ancestors, value)) {
|
|
3026
3523
|
return REDACT_CIRCULAR;
|
|
3027
3524
|
}
|
|
3028
3525
|
if (isError(value)) {
|
|
@@ -3050,7 +3547,8 @@ function walkObject(value, rules, depth2, ancestors, honorToJson, inSerialized)
|
|
|
3050
3547
|
return withBinaryAsSize(value);
|
|
3051
3548
|
}
|
|
3052
3549
|
const resolved = resolveToJson(value, rules.ownFields.safe);
|
|
3053
|
-
|
|
3550
|
+
if (resolved.hostile) return rules.censor;
|
|
3551
|
+
setAdd(ancestors, value);
|
|
3054
3552
|
try {
|
|
3055
3553
|
return walkForm(value, resolved, rules, depth2, ancestors, honorToJson, inSerialized);
|
|
3056
3554
|
} finally {
|
|
@@ -3072,7 +3570,7 @@ function walkForm(value, resolved, rules, depth2, ancestors, honorToJson, inSeri
|
|
|
3072
3570
|
return walkProperties(value, rules, depth2, ancestors, honorToJson, inSerialized);
|
|
3073
3571
|
}
|
|
3074
3572
|
function walkToJsonOutput(value, toJson, rules, depth2, ancestors, inSerialized) {
|
|
3075
|
-
if (Object.keys(value).some((key) => rules.sensitive
|
|
3573
|
+
if (Object.keys(value).some((key) => matchesKey(rules.sensitive, key))) {
|
|
3076
3574
|
return rules.censor;
|
|
3077
3575
|
}
|
|
3078
3576
|
return walk(toJson.call(value), rules, depth2 + 1, ancestors, true, inSerialized);
|
|
@@ -3090,7 +3588,7 @@ function walkProperties(value, rules, depth2, ancestors, honorToJson, inSerializ
|
|
|
3090
3588
|
const current = scrubbed ? ownFieldForLog(source, key, read, rules.ownFields) : read;
|
|
3091
3589
|
const hook = honorToJson && key === "toJSON" && typeof current === "function";
|
|
3092
3590
|
if (current === OMIT_OWN_FIELD || hook) {
|
|
3093
|
-
omitted
|
|
3591
|
+
setAdd(omitted, key);
|
|
3094
3592
|
continue;
|
|
3095
3593
|
}
|
|
3096
3594
|
Reflect.deleteProperty(copy, key);
|
|
@@ -3118,7 +3616,7 @@ function walkProperties(value, rules, depth2, ancestors, honorToJson, inSerializ
|
|
|
3118
3616
|
return copy;
|
|
3119
3617
|
}
|
|
3120
3618
|
function without(keys, omitted) {
|
|
3121
|
-
return keys.filter((key) => !omitted
|
|
3619
|
+
return keys.filter((key) => !setHas(omitted, key));
|
|
3122
3620
|
}
|
|
3123
3621
|
function startCopy(value, asData) {
|
|
3124
3622
|
const clone = isError(value) ? cloneError(value) : void 0;
|
|
@@ -3140,26 +3638,26 @@ function errorPartsHost(rules, ancestors, inSerialized) {
|
|
|
3140
3638
|
}
|
|
3141
3639
|
function createNameRedactor(fieldNames, censor, serializedKeys, maxVisits = REDACT_MAX_VISITS, ownFields = ALL_OWN_FIELDS, errorOnlyNames, headerNames, errorTextToSerializer = false) {
|
|
3142
3640
|
const rules = {
|
|
3143
|
-
sensitive:
|
|
3144
|
-
headerNames:
|
|
3641
|
+
sensitive: foldedNames(fieldNames),
|
|
3642
|
+
headerNames: foldedNames(headerNames ?? fieldNames),
|
|
3145
3643
|
censor,
|
|
3146
|
-
serializedKeys:
|
|
3644
|
+
serializedKeys: capturedSet(serializedKeys),
|
|
3147
3645
|
errorsAsData: serializedKeys !== void 0,
|
|
3148
3646
|
errorTextToSerializer,
|
|
3149
3647
|
maxVisits,
|
|
3150
3648
|
ownFields
|
|
3151
3649
|
};
|
|
3152
|
-
const insideNames = errorOnlyNames === void 0 ? void 0 :
|
|
3650
|
+
const insideNames = errorOnlyNames === void 0 ? void 0 : foldedNames(errorOnlyNames);
|
|
3153
3651
|
return (value, isRecordRoot = false) => {
|
|
3154
3652
|
try {
|
|
3155
3653
|
const visits = { count: 0 };
|
|
3156
|
-
const
|
|
3654
|
+
const call2 = {
|
|
3157
3655
|
...rules,
|
|
3158
3656
|
headerKept: typeof value === "object" && value !== null && errorOutputs.has(value),
|
|
3159
3657
|
visits,
|
|
3160
3658
|
insideErrors: rulesInside(rules, insideNames, visits)
|
|
3161
3659
|
};
|
|
3162
|
-
return walk(value,
|
|
3660
|
+
return walk(value, call2, 0, /* @__PURE__ */ new Set(), !isRecordRoot);
|
|
3163
3661
|
} catch {
|
|
3164
3662
|
return {
|
|
3165
3663
|
_redactionFailed: true,
|
|
@@ -3196,7 +3694,11 @@ function parseResourceAttributes(raw) {
|
|
|
3196
3694
|
} catch {
|
|
3197
3695
|
value = rawValue;
|
|
3198
3696
|
}
|
|
3199
|
-
Object.defineProperty(
|
|
3697
|
+
Object.defineProperty(
|
|
3698
|
+
parsed,
|
|
3699
|
+
key,
|
|
3700
|
+
bareDescriptor({ value, enumerable: true, configurable: true })
|
|
3701
|
+
);
|
|
3200
3702
|
}
|
|
3201
3703
|
return parsed;
|
|
3202
3704
|
}
|
|
@@ -3273,7 +3775,7 @@ function buildResourceBindings(resolved, format, extras = {}) {
|
|
|
3273
3775
|
}
|
|
3274
3776
|
return bindings;
|
|
3275
3777
|
}
|
|
3276
|
-
var OWNED_SERVICE_KEYS =
|
|
3778
|
+
var OWNED_SERVICE_KEYS = capturedSet([
|
|
3277
3779
|
"name",
|
|
3278
3780
|
"version",
|
|
3279
3781
|
"namespace",
|
|
@@ -3420,9 +3922,9 @@ var PATH_SEGMENT = /\[\s*['"]([^'"]+)['"]\s*\]|([^.[\]]+)/g;
|
|
|
3420
3922
|
var INDEX_SEGMENT = /^\d+$/;
|
|
3421
3923
|
function leafNameOf(path2) {
|
|
3422
3924
|
let leaf;
|
|
3423
|
-
for (const match of
|
|
3925
|
+
for (const match of allMatches(PATH_SEGMENT, path2)) {
|
|
3424
3926
|
const quoted = match[1];
|
|
3425
|
-
const name = quoted ?? (match[2] !== void 0 && INDEX_SEGMENT
|
|
3927
|
+
const name = quoted ?? (match[2] !== void 0 && matchesPattern(INDEX_SEGMENT, match[2]) ? void 0 : match[2]);
|
|
3426
3928
|
if (name !== void 0 && name !== "*") {
|
|
3427
3929
|
leaf = name;
|
|
3428
3930
|
}
|
|
@@ -3449,7 +3951,7 @@ function serializeErrorValue(value_, ownFields = ALL_OWN_FIELDS, censorMessage)
|
|
|
3449
3951
|
return serialized;
|
|
3450
3952
|
}
|
|
3451
3953
|
function toEventName(logKey) {
|
|
3452
|
-
return logKey
|
|
3954
|
+
return replaceAllText(lowerCase(logKey), "_", ".");
|
|
3453
3955
|
}
|
|
3454
3956
|
function withEventName(record, field) {
|
|
3455
3957
|
if (field === false) {
|
|
@@ -3474,7 +3976,7 @@ function resolveRecordRedactor(options) {
|
|
|
3474
3976
|
);
|
|
3475
3977
|
}
|
|
3476
3978
|
function wholeRootKeys(options) {
|
|
3477
|
-
return
|
|
3979
|
+
return capturedSet(["logKey", "err", ...Object.keys(options.serializers)]);
|
|
3478
3980
|
}
|
|
3479
3981
|
function ownFieldPolicyOf(options) {
|
|
3480
3982
|
return createOwnFieldPolicy(options.errorOwnFields, options.errorOwnFieldNames);
|
|
@@ -3513,7 +4015,7 @@ function buildNameRedactor(options, nestedErrorsAsData = false, coversNames = tr
|
|
|
3513
4015
|
);
|
|
3514
4016
|
}
|
|
3515
4017
|
function resolveRedactOption(options) {
|
|
3516
|
-
const paths = options.redactStrategy === "paths" ? compileRedactPaths(options.redactPaths, options.shouldDisableDefaultRedact) : [...
|
|
4018
|
+
const paths = options.redactStrategy === "paths" ? compileRedactPaths(options.redactPaths, options.shouldDisableDefaultRedact) : [...capturedSet(options.redactPaths)];
|
|
3517
4019
|
if (paths.length === 0) {
|
|
3518
4020
|
return void 0;
|
|
3519
4021
|
}
|
|
@@ -3556,6 +4058,10 @@ function buildTraceMixin(logContext, options) {
|
|
|
3556
4058
|
censorMessage: buildMessageCensor(options)
|
|
3557
4059
|
});
|
|
3558
4060
|
}
|
|
4061
|
+
var UNSET_ENTRY_NAMES = {
|
|
4062
|
+
levelVal: void 0,
|
|
4063
|
+
write: void 0
|
|
4064
|
+
};
|
|
3559
4065
|
function buildStreams(options, destinations, health) {
|
|
3560
4066
|
const censorMessage = buildMessageCensor(options);
|
|
3561
4067
|
return destinations.map((destination) => {
|
|
@@ -3567,6 +4073,7 @@ function buildStreams(options, destinations, health) {
|
|
|
3567
4073
|
);
|
|
3568
4074
|
health.registerStream(destination, stream);
|
|
3569
4075
|
return {
|
|
4076
|
+
...UNSET_ENTRY_NAMES,
|
|
3570
4077
|
// Guarded: this runs at provider construction, BEFORE any lifecycle hook, so a
|
|
3571
4078
|
// consumer implementing `minLevel` as a throwing getter would fail the factory
|
|
3572
4079
|
// and the application would never start — earlier than any fail-soft path can
|
|
@@ -3623,10 +4130,24 @@ function buildFormatters(options, redactRecord, redactBindings, onTruncate) {
|
|
|
3623
4130
|
log: buildRecordFormatter(options, redactRecord, onTruncate)
|
|
3624
4131
|
};
|
|
3625
4132
|
}
|
|
3626
|
-
|
|
4133
|
+
var UNSET_PINO_NAMES = {
|
|
4134
|
+
transport: void 0,
|
|
4135
|
+
crlf: false,
|
|
4136
|
+
msgPrefix: void 0,
|
|
4137
|
+
name: void 0,
|
|
4138
|
+
writable: false,
|
|
4139
|
+
_writableState: void 0,
|
|
4140
|
+
prettyPrint: void 0,
|
|
4141
|
+
onChild: void 0
|
|
4142
|
+
};
|
|
4143
|
+
function refuseUnsafeOptions(options) {
|
|
4144
|
+
if (!pinoBuiltinsIntact()) throw new Error("LOGGER_BUILTINS_REPLACED");
|
|
3627
4145
|
if (options.maxStringLength !== void 0) {
|
|
3628
4146
|
refuseCensorBeyondLimit(options.redactCensor, options.maxStringLength);
|
|
3629
4147
|
}
|
|
4148
|
+
}
|
|
4149
|
+
function buildPinoInstance(options, logContext, destinations, health) {
|
|
4150
|
+
refuseUnsafeOptions(options);
|
|
3630
4151
|
const redactRecord = resolveRecordRedactor(options);
|
|
3631
4152
|
const redactSerialized = buildNameRedactor(options);
|
|
3632
4153
|
const ownFields = ownFieldPolicyOf(options);
|
|
@@ -3634,10 +4155,10 @@ function buildPinoInstance(options, logContext, destinations, health) {
|
|
|
3634
4155
|
const onTruncate = (reason) => health.recordTruncation(reason);
|
|
3635
4156
|
const pinoOptions = {
|
|
3636
4157
|
level: options.level,
|
|
3637
|
-
...redactOption === void 0 ? {} : { redact: redactOption },
|
|
3638
|
-
|
|
3639
|
-
//
|
|
3640
|
-
// extra attributes
|
|
4158
|
+
...redactOption === void 0 ? {} : { redact: { ...redactOption, remove: false } },
|
|
4159
|
+
...UNSET_PINO_NAMES,
|
|
4160
|
+
// Resource identity, resolved ONCE here rather than per entry: Pino pre-serializes `base` into
|
|
4161
|
+
// the instance's chindings, so the extra attributes cost one string at construction.
|
|
3641
4162
|
base: buildResourceBindings(
|
|
3642
4163
|
resolveServiceMetadata(options.service),
|
|
3643
4164
|
options.resourceFormat,
|
|
@@ -3676,7 +4197,7 @@ var DestinationHealth = class {
|
|
|
3676
4197
|
this.entrySizeTruncations = 0;
|
|
3677
4198
|
this.stringLengthTruncations = 0;
|
|
3678
4199
|
/** Destinations whose `onInit()` rejected. Identity-keyed, not name-keyed. */
|
|
3679
|
-
this.failed =
|
|
4200
|
+
this.failed = capturedSet();
|
|
3680
4201
|
/**
|
|
3681
4202
|
* Destinations that initialized, each with its effective level as an index into
|
|
3682
4203
|
* {@link LOG_LEVEL_PRIORITY}.
|
|
@@ -3702,7 +4223,7 @@ var DestinationHealth = class {
|
|
|
3702
4223
|
* for the whole window — coarser than per-entry tracking, and wrong only in the
|
|
3703
4224
|
* direction that duplicates rather than loses.
|
|
3704
4225
|
*/
|
|
3705
|
-
this.writeFailed =
|
|
4226
|
+
this.writeFailed = capturedSet();
|
|
3706
4227
|
/**
|
|
3707
4228
|
* In-flight asynchronous writes per destination.
|
|
3708
4229
|
*
|
|
@@ -3958,20 +4479,21 @@ var HookTimeoutError = class extends Error {
|
|
|
3958
4479
|
}
|
|
3959
4480
|
};
|
|
3960
4481
|
function withTimeout(work, ms) {
|
|
3961
|
-
|
|
4482
|
+
const wait = new IntrinsicPromise((resolve, reject2) => {
|
|
3962
4483
|
const timer = setTimeout(() => {
|
|
3963
4484
|
reject2(new HookTimeoutError(ms));
|
|
3964
4485
|
}, ms);
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
}
|
|
4486
|
+
awaitOutcome(work, (outcome) => {
|
|
4487
|
+
if (outcome.ok) resolve();
|
|
4488
|
+
else reject2(outcome.cause);
|
|
4489
|
+
try {
|
|
4490
|
+
clearTimeout(timer);
|
|
4491
|
+
} catch {
|
|
4492
|
+
}
|
|
4493
|
+
});
|
|
3974
4494
|
});
|
|
4495
|
+
absorb(wait);
|
|
4496
|
+
return tag(wait);
|
|
3975
4497
|
}
|
|
3976
4498
|
|
|
3977
4499
|
// src/server/services/destination-registry.service.ts
|
|
@@ -4021,7 +4543,9 @@ var DestinationRegistry = class {
|
|
|
4021
4543
|
async onModuleInit() {
|
|
4022
4544
|
for (const destination of this.registered) {
|
|
4023
4545
|
try {
|
|
4024
|
-
await
|
|
4546
|
+
await intactOr(
|
|
4547
|
+
withTimeout(() => destination.onInit?.(), this.options.destinationHookTimeoutMs)
|
|
4548
|
+
);
|
|
4025
4549
|
this.active.push(destination);
|
|
4026
4550
|
this.health.markHealthy(destination, this.effectiveLevelOf(destination));
|
|
4027
4551
|
} catch (cause) {
|
|
@@ -4053,14 +4577,16 @@ var DestinationRegistry = class {
|
|
|
4053
4577
|
async notifyRegistryReady() {
|
|
4054
4578
|
for (const destination of this.registered) {
|
|
4055
4579
|
try {
|
|
4056
|
-
await
|
|
4057
|
-
(
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4580
|
+
await intactOr(
|
|
4581
|
+
withTimeout(
|
|
4582
|
+
() => destination.onRegistryReady?.({
|
|
4583
|
+
heldEntriesDeliveredElsewhere: this.health.deliveredByHealthySink(
|
|
4584
|
+
destination,
|
|
4585
|
+
this.effectiveLevelOf(destination)
|
|
4586
|
+
)
|
|
4587
|
+
}),
|
|
4588
|
+
this.options.destinationHookTimeoutMs
|
|
4589
|
+
)
|
|
4064
4590
|
);
|
|
4065
4591
|
} catch (cause) {
|
|
4066
4592
|
this.reportHookFailure(destination, cause);
|
|
@@ -4202,7 +4728,7 @@ var DestinationRegistry = class {
|
|
|
4202
4728
|
continue;
|
|
4203
4729
|
}
|
|
4204
4730
|
try {
|
|
4205
|
-
await withTimeout(() => destination.onShutdown?.(), remaining);
|
|
4731
|
+
await intactOr(withTimeout(() => destination.onShutdown?.(), remaining));
|
|
4206
4732
|
} catch (cause) {
|
|
4207
4733
|
this.reportShutdownFailure(destination, cause);
|
|
4208
4734
|
}
|
|
@@ -4581,7 +5107,7 @@ function productionRefusal() {
|
|
|
4581
5107
|
);
|
|
4582
5108
|
}
|
|
4583
5109
|
async function buildTransform(view) {
|
|
4584
|
-
const { build } = await import('pino-pretty');
|
|
5110
|
+
const { build } = await tag(import('pino-pretty'));
|
|
4585
5111
|
return build({
|
|
4586
5112
|
...DEFAULT_VIEW,
|
|
4587
5113
|
...view,
|
|
@@ -4658,7 +5184,7 @@ var PrettyDevDestination = class {
|
|
|
4658
5184
|
throw productionRefusal();
|
|
4659
5185
|
}
|
|
4660
5186
|
try {
|
|
4661
|
-
this.stream = await buildTransform(this.view);
|
|
5187
|
+
this.stream = await tag(buildTransform(this.view));
|
|
4662
5188
|
} catch (cause) {
|
|
4663
5189
|
this.initFailed = true;
|
|
4664
5190
|
throw initFailure(cause);
|