@sendhome/common 1.0.164 → 1.0.166

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.
@@ -19,6 +19,7 @@ const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
19
19
  const requireAuth = (sessionServiceUrl) => {
20
20
  return (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
21
21
  var _a;
22
+ console.log("req.cookies.token", req.cookies.token);
22
23
  try {
23
24
  const token = req.cookies.token || ((_a = req.headers.authorization) === null || _a === void 0 ? void 0 : _a.split(' ')[1]);
24
25
  if (!token) {
@@ -41,7 +42,17 @@ const requireAuth = (sessionServiceUrl) => {
41
42
  next();
42
43
  }
43
44
  catch (error) {
44
- res.status(500).json({ message: 'Server error during session validation', error });
45
+ console.error("Error during session validation:", error);
46
+ // Check if error is an Axios error (e.g., network failure or service unreachable)
47
+ if (axios_1.default.isAxiosError(error)) {
48
+ res.status(500).json({ message: 'Error connecting to session service', error: error.message });
49
+ }
50
+ else if (error.name === 'JsonWebTokenError') {
51
+ res.status(401).json({ message: 'Invalid JWT token', error: error.message });
52
+ }
53
+ else {
54
+ res.status(500).json({ message: 'Server error during session validation', error });
55
+ }
45
56
  }
46
57
  });
47
58
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sendhome/common",
3
- "version": "1.0.164",
3
+ "version": "1.0.166",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",