@onesub/server 0.23.0 → 0.23.2

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.
@@ -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,16 @@ 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/g, "\\r").replace(/\n/g, "\\n").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
180
+ }
181
+ function scrub(args) {
182
+ return args.map((arg) => typeof arg === "string" ? escapeLineBreaks(arg) : arg);
183
+ }
178
184
  var log = {
179
- info: (...args) => current.info(...args),
180
- warn: (...args) => current.warn(...args),
181
- error: (...args) => current.error(...args)
185
+ info: (...args) => current.info(...scrub(args)),
186
+ warn: (...args) => current.warn(...scrub(args)),
187
+ error: (...args) => current.error(...scrub(args))
182
188
  };
183
189
 
184
190
  // src/http.ts