@riocrypto/common 1.0.404 → 1.0.406

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.
@@ -5,7 +5,7 @@ const custom_error_1 = require("./custom-error");
5
5
  class MissingPasswordError extends custom_error_1.CustomError {
6
6
  constructor() {
7
7
  super("Password is not registered");
8
- this.statusCode = 400;
8
+ this.statusCode = 401;
9
9
  Object.setPrototypeOf(this, MissingPasswordError.prototype);
10
10
  }
11
11
  serializeErrors() {
@@ -5,7 +5,7 @@ const custom_error_1 = require("./custom-error");
5
5
  class MissingSecurityQuestionError extends custom_error_1.CustomError {
6
6
  constructor() {
7
7
  super("Security question is not registered");
8
- this.statusCode = 400;
8
+ this.statusCode = 401;
9
9
  Object.setPrototypeOf(this, MissingSecurityQuestionError.prototype);
10
10
  }
11
11
  serializeErrors() {
@@ -25,7 +25,7 @@ const missing_user_error_1 = require("../errors/missing-user-error");
25
25
  const missing_password_error_1 = require("../errors/missing-password-error");
26
26
  const missing_security_question_error_1 = require("../errors/missing-security-question-error");
27
27
  const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(void 0, void 0, void 0, function* () {
28
- var _a, _b, _c, _d, _e, _f, _g;
28
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
29
29
  let missingKYC = false;
30
30
  if (authorizationTypes.includes(authorization_type_1.AuthorizationType.Auth) ||
31
31
  authorizationTypes.includes(authorization_type_1.AuthorizationType.UserNoKYC) ||
@@ -39,15 +39,18 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
39
39
  }
40
40
  console.log("req.currentAuth");
41
41
  console.log(req.currentAuth);
42
- if ((_c = (_b = req.currentAuth) === null || _b === void 0 ? void 0 : _b.missing) === null || _c === void 0 ? void 0 : _c.includes("password")) {
42
+ console.log((_b = req.currentAuth) === null || _b === void 0 ? void 0 : _b.missing);
43
+ console.log((_d = (_c = req.currentAuth) === null || _c === void 0 ? void 0 : _c.missing) === null || _d === void 0 ? void 0 : _d.includes("password"));
44
+ if ((_f = (_e = req.currentAuth) === null || _e === void 0 ? void 0 : _e.missing) === null || _f === void 0 ? void 0 : _f.includes("password")) {
45
+ console.log("hit");
43
46
  throw new missing_password_error_1.MissingPasswordError();
44
47
  }
45
- if ((_e = (_d = req.currentAuth) === null || _d === void 0 ? void 0 : _d.missing) === null || _e === void 0 ? void 0 : _e.includes("securityQuestion")) {
48
+ if ((_h = (_g = req.currentAuth) === null || _g === void 0 ? void 0 : _g.missing) === null || _h === void 0 ? void 0 : _h.includes("securityQuestion")) {
46
49
  throw new missing_security_question_error_1.MissingSecurityQuestionError();
47
50
  }
48
51
  }
49
52
  if (authorizationTypes.includes(authorization_type_1.AuthorizationType.Admin)) {
50
- if ((_f = req.cookies) === null || _f === void 0 ? void 0 : _f.adminJwt) {
53
+ if ((_j = req.cookies) === null || _j === void 0 ? void 0 : _j.adminJwt) {
51
54
  try {
52
55
  const payload = jsonwebtoken_1.default.verify(req.cookies.adminJwt, process.env.JWT_KEY_ADMIN);
53
56
  req.currentAdminAuth = payload;
@@ -136,7 +139,7 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
136
139
  if (missingKYC) {
137
140
  throw new missing_kyc_approval_error_1.MissingKYCApprovalError();
138
141
  }
139
- if ((_g = req.cookies) === null || _g === void 0 ? void 0 : _g.jwt) {
142
+ if ((_k = req.cookies) === null || _k === void 0 ? void 0 : _k.jwt) {
140
143
  throw new missing_user_error_1.MissingUserError();
141
144
  }
142
145
  throw new not_authorized_error_1.NotAuthorizedError();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common",
3
- "version": "1.0.404",
3
+ "version": "1.0.406",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",