@onesub/server 0.23.0 → 0.23.1
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/dist/__tests__/logger.test.d.ts +11 -0
- package/dist/__tests__/logger.test.d.ts.map +1 -0
- package/dist/index.cjs +13 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The process-wide logger, and specifically that a caller cannot forge log lines.
|
|
3
|
+
*
|
|
4
|
+
* Much of what this server logs is attacker-influenced — `userId` arrives in the
|
|
5
|
+
* request body, and bundle ids, package names and receipt previews come out of
|
|
6
|
+
* submitted receipts. A newline in any of those would let a caller end the current
|
|
7
|
+
* line and write an entry of their own, and these logs are what support and fraud
|
|
8
|
+
* decisions get read from.
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=logger.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/logger.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
package/dist/index.cjs
CHANGED
|
@@ -175,10 +175,20 @@ var current = console;
|
|
|
175
175
|
function setLogger(logger) {
|
|
176
176
|
if (logger) current = logger;
|
|
177
177
|
}
|
|
178
|
+
function escapeLineBreaks(value) {
|
|
179
|
+
return value.replace(/[\r\n\u2028\u2029]/g, (ch) => {
|
|
180
|
+
if (ch === "\n") return "\\n";
|
|
181
|
+
if (ch === "\r") return "\\r";
|
|
182
|
+
return `\\u${ch.charCodeAt(0).toString(16).padStart(4, "0")}`;
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
function scrub(args) {
|
|
186
|
+
return args.map((arg) => typeof arg === "string" ? escapeLineBreaks(arg) : arg);
|
|
187
|
+
}
|
|
178
188
|
var log = {
|
|
179
|
-
info: (...args) => current.info(...args),
|
|
180
|
-
warn: (...args) => current.warn(...args),
|
|
181
|
-
error: (...args) => current.error(...args)
|
|
189
|
+
info: (...args) => current.info(...scrub(args)),
|
|
190
|
+
warn: (...args) => current.warn(...scrub(args)),
|
|
191
|
+
error: (...args) => current.error(...scrub(args))
|
|
182
192
|
};
|
|
183
193
|
|
|
184
194
|
// src/http.ts
|