nucleus-core-ts 0.10.20 → 0.10.21

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.
@@ -27,3 +27,26 @@ export declare function resolveClientIp(socketIp: string | null | undefined, for
27
27
  * 1350 of them on a dashboard route, all keyed by `::ffff:127.0.0.1`.
28
28
  */
29
29
  export declare const isNonDiscriminatingPeer: (ip: string) => boolean;
30
+ /**
31
+ * Watches whether the peer address ever varies.
32
+ *
33
+ * `isNonDiscriminatingPeer` only recognises loopback, which catches a frontend
34
+ * on the same host and nothing else. The identical failure happens whenever the
35
+ * API is reached through one hop that is not declared as a trusted proxy -- a
36
+ * frontend pod calling a cluster IP, a sidecar, a NAT gateway. Those addresses
37
+ * look perfectly ordinary, so no shape test can spot them.
38
+ *
39
+ * What CAN be spotted is the consequence: if every request the process has ever
40
+ * seen arrived from one address, that address is not telling callers apart, and
41
+ * every rate-limit bucket keyed on it is one counter for everybody. So this
42
+ * observes instead of guessing, and gives up the moment a second address shows
43
+ * up -- a deployment with real client addresses pays one Set lookup and is never
44
+ * bothered again.
45
+ */
46
+ export declare function createPeerDiversityWatcher(sampleSize?: number): {
47
+ /**
48
+ * Returns the single address once it is established that every caller
49
+ * shares it, and null otherwise. Answers at most once.
50
+ */
51
+ observe(ip: string): string | null;
52
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nucleus-core-ts",
3
- "version": "0.10.20",
3
+ "version": "0.10.21",
4
4
  "description": "Production-ready, enterprise-grade TypeScript framework for building multi-tenant APIs",
5
5
  "author": "Hidayet Can Özcan <hidayetcan@gmail.com>",
6
6
  "license": "SEE LICENSE IN LICENSE",