powr-sdk-api 4.8.2 → 4.8.4

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.
@@ -10,7 +10,7 @@ const generateJWTToken = (user, profile = null) => {
10
10
  fullName: user.fullName,
11
11
  access: profile === null || profile === void 0 ? void 0 : profile.access
12
12
  }, config.jwtToken, {
13
- expiresIn: '7d'
13
+ expiresIn: '24h'
14
14
  });
15
15
  };
16
16
  const generateRefreshToken = user => {
@@ -1,46 +1,19 @@
1
1
  "use strict";
2
2
 
3
- /**
4
- * Best-effort client IP from the incoming HTTP request
5
- * (uses X-Forwarded-For, X-Real-IP, req.ip, or socket address).
3
+ /**
4
+ * Best-effort client IP from the incoming HTTP request
5
+ * (uses X-Forwarded-For, X-Real-IP, req.ip, or socket address).
6
6
  */
7
7
  function getClientIp(req) {
8
- const h = req.headers || {};
9
- const signals = {
10
- "x-forwarded-for": h["x-forwarded-for"],
11
- "x-real-ip": h["x-real-ip"],
12
- "cf-connecting-ip": h["cf-connecting-ip"],
13
- "true-client-ip": h["true-client-ip"],
14
- "x-client-ip": h["x-client-ip"],
15
- forwarded: h["forwarded"],
16
- reqIp: req.ip,
17
- socketRemoteAddress: req.socket && req.socket.remoteAddress,
18
- connectionRemoteAddress: req.connection && req.connection.remoteAddress
19
- };
20
- console.log("[getClientIp] IP signals (all candidates):", JSON.stringify(signals));
21
- const forwarded = h["x-forwarded-for"];
8
+ const forwarded = req.headers["x-forwarded-for"];
22
9
  if (typeof forwarded === "string" && forwarded.length > 0) {
23
10
  const first = forwarded.split(",")[0].trim();
24
- if (first) {
25
- console.log("[getClientIp] chosen: x-forwarded-for (first hop) ->", first);
26
- return first;
27
- }
11
+ if (first) return first;
28
12
  }
29
- const realIp = h["x-real-ip"];
30
- if (typeof realIp === "string" && realIp.trim()) {
31
- const v = realIp.trim();
32
- console.log("[getClientIp] chosen: x-real-ip ->", v);
33
- return v;
34
- }
35
- if (req.ip) {
36
- console.log("[getClientIp] chosen: req.ip ->", req.ip);
37
- return req.ip;
38
- }
39
- if (req.socket && req.socket.remoteAddress) {
40
- console.log("[getClientIp] chosen: socket.remoteAddress ->", req.socket.remoteAddress);
41
- return req.socket.remoteAddress;
42
- }
43
- console.log("[getClientIp] chosen: none (no usable IP)");
13
+ const realIp = req.headers["x-real-ip"];
14
+ if (typeof realIp === "string" && realIp.trim()) return realIp.trim();
15
+ if (req.ip) return req.ip;
16
+ if (req.socket && req.socket.remoteAddress) return req.socket.remoteAddress;
44
17
  return null;
45
18
  }
46
19
  module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "powr-sdk-api",
3
- "version": "4.8.2",
3
+ "version": "4.8.4",
4
4
  "description": "Shared API core library for PowrStack projects. Zero dependencies - works with Express, Next.js API routes, and other frameworks. All features are optional and install only what you need.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",