@onesub/server 0.23.3 → 0.24.0

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,68 @@
1
+ /**
2
+ * Renders a log call into exactly one string.
3
+ *
4
+ * Why this module exists, and why it is pure. `logger.ts` holds process-global
5
+ * state, so anything tested through it needs `setLogger` juggling to keep one test
6
+ * file from capturing another's output. Every security property below is a property
7
+ * of a function from arguments to a string, so it belongs somewhere with no state
8
+ * at all — see `log-format.test.ts`.
9
+ *
10
+ * ## The invariant
11
+ *
12
+ * **No byte supplied by a caller can begin a line.**
13
+ *
14
+ * That is the whole security claim, and it is weaker than "the output contains no
15
+ * newlines" on purpose. Demanding no newlines at all is what backed this server
16
+ * into a corner earlier: a stack trace is multi-line by nature and is the main
17
+ * reason to log an `Error`, so flattening it destroys the thing you wanted. Framing
18
+ * it as "attacker text may appear inside a record, never at the start of one" keeps
19
+ * the trace readable *and* makes forgery impossible.
20
+ *
21
+ * It holds mechanically: the message and every field value pass through `esc`,
22
+ * which leaves no line terminator behind, so the only newlines in the result are the
23
+ * ones this module writes itself as part of `LOG_CONTINUATION`. A forged
24
+ * `[onesub] admin granted premium to mallory` line cannot be produced.
25
+ *
26
+ * `LOG_CONTINUATION` begins with whitespace, which is what Fluent Bit, Loki and
27
+ * Docker multiline rules already use to join a line to the record above it. And
28
+ * grepping `[onesub/` still returns one hit per event, not one per stack frame.
29
+ *
30
+ * ## Output grammar
31
+ *
32
+ * ```text
33
+ * <message>[ <key>=<value>]*[<CONT><line>]*
34
+ * ```
35
+ *
36
+ * ## Field vocabulary
37
+ *
38
+ * Use these names and no synonyms — `userId`, not `user` or `uid`. The point of
39
+ * moving values out of the message is that an operator can filter on them, and that
40
+ * is lost the moment the same thing is called three things across 16 files:
41
+ *
42
+ * route · provider · userId · appId · platform · productId · transactionId ·
43
+ * originalTransactionId · purchaseToken · orderId · bundleId · packageName ·
44
+ * notificationType · status · httpStatus · environment · err
45
+ *
46
+ * `err` is reserved: it always routes through the error renderer.
47
+ *
48
+ * Messages are static literals. Write `log.warn('bundle id mismatch', { bundleId,
49
+ * expected })`, never `` log.warn(`mismatch: ${a} !== ${b}`) `` — an interpolated
50
+ * value is a value that cannot be filtered on, and one that has to be escaped
51
+ * rather than simply carried.
52
+ */
53
+ /**
54
+ * Prefix for every line after the first. Leading whitespace is deliberate: it is
55
+ * what existing log-shipper multiline rules key on.
56
+ */
57
+ export declare const LOG_CONTINUATION = "\n | ";
58
+ /**
59
+ * Render a whole log call into one string.
60
+ *
61
+ * Argument handling is generic rather than a fixed `(message, fields)` shape, and
62
+ * that is what makes the call-site migration incremental: a site still passing
63
+ * printf-style varargs renders sensibly, so files can move one PR at a time with no
64
+ * flag day. Strings join the message, plain objects contribute their entries as
65
+ * fields, `Error`s go through the error renderer wherever they appear.
66
+ */
67
+ export declare function formatLogArgs(args: readonly unknown[]): string;
68
+ //# sourceMappingURL=log-format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-format.d.ts","sourceRoot":"","sources":["../src/log-format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH;;;GAGG;AACH,eAAO,MAAM,gBAAgB,aAAa,CAAC;AA+K3C;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAgC9D"}
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAcnD,wBAAgB,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,GAAG,IAAI,CAEhE;AAgED,eAAO,MAAM,GAAG,EAAE,YAIjB,CAAC"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAkCnD,wBAAgB,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,GAAG,IAAI,CAEhE;AAED,eAAO,MAAM,GAAG,EAAE,YAIjB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onesub/server",
3
- "version": "0.23.3",
3
+ "version": "0.24.0",
4
4
  "description": "Server-side receipt validation middleware for react-native-iap. Apple StoreKit 2 + Google Play Billing. One line.",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -55,7 +55,7 @@
55
55
  },
56
56
  "license": "MIT",
57
57
  "dependencies": {
58
- "@onesub/shared": "0.15.0",
58
+ "@onesub/shared": "0.15.1",
59
59
  "jose": "^6.2.3",
60
60
  "zod": "^4.4.3"
61
61
  },