@riocrypto/common 1.0.392 → 1.0.395

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.
@@ -21,8 +21,9 @@ const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
21
21
  const not_authorized_error_1 = require("../errors/not-authorized-error");
22
22
  const kyc_status_1 = require("../types/kyc-status");
23
23
  const missing_kyc_approval_error_1 = require("../errors/missing-kyc-approval-error");
24
+ const missing_user_error_1 = require("../errors/missing-user-error");
24
25
  const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(void 0, void 0, void 0, function* () {
25
- var _a, _b;
26
+ var _a, _b, _c;
26
27
  let missingKYC = false;
27
28
  if (authorizationTypes.includes(authorization_type_1.AuthorizationType.Auth)) {
28
29
  if ((_a = req.cookies) === null || _a === void 0 ? void 0 : _a.jwt) {
@@ -106,6 +107,15 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
106
107
  req.user = user;
107
108
  }
108
109
  }
110
+ if ((_c = req.cookies) === null || _c === void 0 ? void 0 : _c.jwt) {
111
+ try {
112
+ const payload = jsonwebtoken_1.default.verify(req.cookies.jwt, process.env.JWT_KEY);
113
+ if (authorizationTypes.includes(authorization_type_1.AuthorizationType.User) && !req.user) {
114
+ throw new missing_user_error_1.MissingUserError();
115
+ }
116
+ }
117
+ catch (err) { }
118
+ }
109
119
  if (!req.currentAdminAuth && !req.currentAuth && !req.user) {
110
120
  if (missingKYC) {
111
121
  throw new missing_kyc_approval_error_1.MissingKYCApprovalError();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common",
3
- "version": "1.0.392",
3
+ "version": "1.0.395",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",