@bbloker/sdk 0.3.0 → 0.4.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.
@@ -45,7 +45,7 @@ function normalizeExpressRequest(req) {
45
45
  headerNames.push(lower);
46
46
  }
47
47
  const forwarded = _optionalChain([headers, 'access', _ => _["x-forwarded-for"], 'optionalAccess', _2 => _2.split, 'call', _3 => _3(","), 'access', _4 => _4[0], 'optionalAccess', _5 => _5.trim, 'call', _6 => _6()]);
48
- const ip = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(req.ip, () => ( forwarded)), () => ( _optionalChain([req, 'access', _7 => _7.socket, 'optionalAccess', _8 => _8.remoteAddress]))), () => ( "0.0.0.0"));
48
+ const ip = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(forwarded, () => ( req.ip)), () => ( _optionalChain([req, 'access', _7 => _7.socket, 'optionalAccess', _8 => _8.remoteAddress]))), () => ( "0.0.0.0"));
49
49
  return {
50
50
  ip,
51
51
  userAgent: _nullishCoalesce(headers["user-agent"], () => ( "")),
@@ -45,7 +45,7 @@ function normalizeExpressRequest(req) {
45
45
  headerNames.push(lower);
46
46
  }
47
47
  const forwarded = headers["x-forwarded-for"]?.split(",")[0]?.trim();
48
- const ip = req.ip ?? forwarded ?? req.socket?.remoteAddress ?? "0.0.0.0";
48
+ const ip = forwarded ?? req.ip ?? req.socket?.remoteAddress ?? "0.0.0.0";
49
49
  return {
50
50
  ip,
51
51
  userAgent: headers["user-agent"] ?? "",
@@ -48,7 +48,7 @@ function normalizeFastifyRequest(req) {
48
48
  headerNames.push(lower);
49
49
  }
50
50
  const forwarded = _optionalChain([headers, 'access', _ => _["x-forwarded-for"], 'optionalAccess', _2 => _2.split, 'call', _3 => _3(","), 'access', _4 => _4[0], 'optionalAccess', _5 => _5.trim, 'call', _6 => _6()]);
51
- const ip = _nullishCoalesce(_nullishCoalesce(req.ip, () => ( forwarded)), () => ( "0.0.0.0"));
51
+ const ip = _nullishCoalesce(_nullishCoalesce(forwarded, () => ( req.ip)), () => ( "0.0.0.0"));
52
52
  return {
53
53
  ip,
54
54
  userAgent: _nullishCoalesce(headers["user-agent"], () => ( "")),
@@ -48,7 +48,7 @@ function normalizeFastifyRequest(req) {
48
48
  headerNames.push(lower);
49
49
  }
50
50
  const forwarded = headers["x-forwarded-for"]?.split(",")[0]?.trim();
51
- const ip = req.ip ?? forwarded ?? "0.0.0.0";
51
+ const ip = forwarded ?? req.ip ?? "0.0.0.0";
52
52
  return {
53
53
  ip,
54
54
  userAgent: headers["user-agent"] ?? "",
@@ -39,7 +39,7 @@ function normalizeNextRequest(req) {
39
39
  headerNames.push(lower);
40
40
  });
41
41
  return {
42
- ip: _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(req.ip, () => ( _optionalChain([headers, 'access', _ => _["x-forwarded-for"], 'optionalAccess', _2 => _2.split, 'call', _3 => _3(","), 'access', _4 => _4[0], 'optionalAccess', _5 => _5.trim, 'call', _6 => _6()]))), () => ( headers["x-real-ip"])), () => ( "0.0.0.0")),
42
+ ip: _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([headers, 'access', _ => _["x-forwarded-for"], 'optionalAccess', _2 => _2.split, 'call', _3 => _3(","), 'access', _4 => _4[0], 'optionalAccess', _5 => _5.trim, 'call', _6 => _6()]), () => ( headers["x-real-ip"])), () => ( req.ip)), () => ( "0.0.0.0")),
43
43
  userAgent: _nullishCoalesce(headers["user-agent"], () => ( "")),
44
44
  headers,
45
45
  headerNames,
@@ -39,7 +39,7 @@ function normalizeNextRequest(req) {
39
39
  headerNames.push(lower);
40
40
  });
41
41
  return {
42
- ip: req.ip ?? headers["x-forwarded-for"]?.split(",")[0]?.trim() ?? headers["x-real-ip"] ?? "0.0.0.0",
42
+ ip: headers["x-forwarded-for"]?.split(",")[0]?.trim() ?? headers["x-real-ip"] ?? req.ip ?? "0.0.0.0",
43
43
  userAgent: headers["user-agent"] ?? "",
44
44
  headers,
45
45
  headerNames,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbloker/sdk",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "description": "AI bot blocker SDK — shared intelligence network to detect and block AI crawlers",
6
6
  "sideEffects": false,