vr-commons 1.0.79 → 1.0.81

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.
@@ -39,11 +39,6 @@ const checkUserAuthentication = (allowedRoles) => async (req, res, next) => {
39
39
  if (!user || !user.securityClearance) {
40
40
  return (0, __1.sendErrorResponse)(res, "User not found", 400);
41
41
  }
42
- // Check account moderation status
43
- const moderation = await (0, __1.checkIsUserBannedOrSuspended)(user.id);
44
- if (moderation.isRestricted) {
45
- return (0, __1.sendErrorResponse)(res, "Account restricted", 403, moderation);
46
- }
47
42
  // 🔐 Token versioning (logout all devices)
48
43
  if (user.tokenVersion !== payload.tokenVersion) {
49
44
  return (0, __1.sendErrorResponse)(res, "Session expired. Please re-verify your phone.", 401);
@@ -6,7 +6,7 @@ const sendSuccessResponse = (res, message, data = null, statusCode = 200) => {
6
6
  res.status(statusCode).json({
7
7
  success: true,
8
8
  message,
9
- data
9
+ data,
10
10
  });
11
11
  };
12
12
  exports.sendSuccessResponse = sendSuccessResponse;
@@ -16,7 +16,7 @@ const sendErrorResponse = (res, message, statusCode = 400, error = null) => {
16
16
  res.status(statusCode).json({
17
17
  success: false,
18
18
  message,
19
- error: error?.message || error
19
+ ...(error && { error: error.message || error }),
20
20
  });
21
21
  };
22
22
  exports.sendErrorResponse = sendErrorResponse;
@@ -9,7 +9,7 @@ const validate = (schema) => async (req, res, next) => {
9
9
  body: req.body,
10
10
  query: req.query,
11
11
  params: req.params,
12
- headers: req.headers // Add headers to validation
12
+ headers: req.headers,
13
13
  });
14
14
  // Store validated values in custom properties
15
15
  req.validatedBody = result.body;
@@ -21,14 +21,16 @@ const validate = (schema) => async (req, res, next) => {
21
21
  return next();
22
22
  }
23
23
  catch (error) {
24
- console.error(" validate middleware function Error::::::", error);
24
+ console.error("validate middleware function Error::::::", error);
25
25
  if (error instanceof zod_1.ZodError) {
26
+ // Match the same format as sendErrorResponse
26
27
  res.status(400).json({
27
- status: "fail",
28
+ success: false,
29
+ message: "Validation failed",
28
30
  errors: error.errors.map((err) => ({
29
31
  path: err.path.join("."),
30
- message: err.message
31
- }))
32
+ message: err.message,
33
+ })),
32
34
  });
33
35
  return;
34
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vr-commons",
3
- "version": "1.0.79",
3
+ "version": "1.0.81",
4
4
  "description": "Shared functions package",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",