@common_ch/common 1.0.359 → 1.0.360

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.
@@ -14,4 +14,5 @@ declare global {
14
14
  }
15
15
  }
16
16
  export declare const currentUser: (req: Request, res: Response, next: NextFunction) => Promise<void>;
17
+ export declare const currentUserSocket: (token: string) => Promise<UserPayload | null>;
17
18
  export {};
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.currentUser = void 0;
15
+ exports.currentUserSocket = exports.currentUser = void 0;
16
16
  const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
17
17
  const redis_service_1 = require("../services/redis/redis.service");
18
18
  const currentUser = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
@@ -32,3 +32,19 @@ const currentUser = (req, res, next) => __awaiter(void 0, void 0, void 0, functi
32
32
  next();
33
33
  });
34
34
  exports.currentUser = currentUser;
35
+ const currentUserSocket = (token) => __awaiter(void 0, void 0, void 0, function* () {
36
+ try {
37
+ const isTokenBlocked = yield (0, redis_service_1.getCacheTokenAuth)(token);
38
+ if (!isTokenBlocked) {
39
+ const payload = jsonwebtoken_1.default.verify(token, process.env.JWT_KEY);
40
+ return payload;
41
+ }
42
+ else {
43
+ return null;
44
+ }
45
+ }
46
+ catch (err) {
47
+ return null;
48
+ }
49
+ });
50
+ exports.currentUserSocket = currentUserSocket;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@common_ch/common",
3
- "version": "1.0.359",
3
+ "version": "1.0.360",
4
4
  "main": "./build/index.js",
5
5
  "types": "./build/index.d.ts",
6
6
  "files": [