@riocrypto/common 1.0.406 → 1.0.407

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.
@@ -0,0 +1,8 @@
1
+ import { CustomError } from "./custom-error";
2
+ export declare class WrongOrderStateError extends CustomError {
3
+ statusCode: number;
4
+ constructor();
5
+ serializeErrors(): {
6
+ message: string;
7
+ }[];
8
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WrongOrderStateError = void 0;
4
+ const custom_error_1 = require("./custom-error");
5
+ class WrongOrderStateError extends custom_error_1.CustomError {
6
+ constructor() {
7
+ super("Order is not in the correct state to call this method");
8
+ this.statusCode = 400;
9
+ Object.setPrototypeOf(this, WrongOrderStateError.prototype);
10
+ }
11
+ serializeErrors() {
12
+ return [
13
+ { message: "Order is not in the correct state to call this method" },
14
+ ];
15
+ }
16
+ }
17
+ exports.WrongOrderStateError = WrongOrderStateError;
package/build/index.d.ts CHANGED
@@ -19,6 +19,7 @@ export * from "./errors/missing-security-question-error";
19
19
  export * from "./errors/api-key-not-found-error";
20
20
  export * from "./errors/missing-user-error";
21
21
  export * from "./errors/missing-kyc-approval-error";
22
+ export * from "./errors/wrong-order-state-error";
22
23
  export * from "./middlewares/error-handler";
23
24
  export * from "./middlewares/validate-request";
24
25
  export * from "./middlewares/current-auth";
package/build/index.js CHANGED
@@ -35,6 +35,7 @@ __exportStar(require("./errors/missing-security-question-error"), exports);
35
35
  __exportStar(require("./errors/api-key-not-found-error"), exports);
36
36
  __exportStar(require("./errors/missing-user-error"), exports);
37
37
  __exportStar(require("./errors/missing-kyc-approval-error"), exports);
38
+ __exportStar(require("./errors/wrong-order-state-error"), exports);
38
39
  __exportStar(require("./middlewares/error-handler"), exports);
39
40
  __exportStar(require("./middlewares/validate-request"), exports);
40
41
  __exportStar(require("./middlewares/current-auth"), exports);
@@ -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, _h, _j, _k;
28
+ var _a, _b, _c, _d, _e, _f, _g;
29
29
  let missingKYC = false;
30
30
  if (authorizationTypes.includes(authorization_type_1.AuthorizationType.Auth) ||
31
31
  authorizationTypes.includes(authorization_type_1.AuthorizationType.UserNoKYC) ||
@@ -37,20 +37,16 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
37
37
  }
38
38
  catch (err) { }
39
39
  }
40
- console.log("req.currentAuth");
41
- console.log(req.currentAuth);
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")) {
40
+ if ((_c = (_b = req.currentAuth) === null || _b === void 0 ? void 0 : _b.missing) === null || _c === void 0 ? void 0 : _c.includes("password")) {
45
41
  console.log("hit");
46
42
  throw new missing_password_error_1.MissingPasswordError();
47
43
  }
48
- if ((_h = (_g = req.currentAuth) === null || _g === void 0 ? void 0 : _g.missing) === null || _h === void 0 ? void 0 : _h.includes("securityQuestion")) {
44
+ if ((_e = (_d = req.currentAuth) === null || _d === void 0 ? void 0 : _d.missing) === null || _e === void 0 ? void 0 : _e.includes("securityQuestion")) {
49
45
  throw new missing_security_question_error_1.MissingSecurityQuestionError();
50
46
  }
51
47
  }
52
48
  if (authorizationTypes.includes(authorization_type_1.AuthorizationType.Admin)) {
53
- if ((_j = req.cookies) === null || _j === void 0 ? void 0 : _j.adminJwt) {
49
+ if ((_f = req.cookies) === null || _f === void 0 ? void 0 : _f.adminJwt) {
54
50
  try {
55
51
  const payload = jsonwebtoken_1.default.verify(req.cookies.adminJwt, process.env.JWT_KEY_ADMIN);
56
52
  req.currentAdminAuth = payload;
@@ -139,7 +135,7 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
139
135
  if (missingKYC) {
140
136
  throw new missing_kyc_approval_error_1.MissingKYCApprovalError();
141
137
  }
142
- if ((_k = req.cookies) === null || _k === void 0 ? void 0 : _k.jwt) {
138
+ if ((_g = req.cookies) === null || _g === void 0 ? void 0 : _g.jwt) {
143
139
  throw new missing_user_error_1.MissingUserError();
144
140
  }
145
141
  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.406",
3
+ "version": "1.0.407",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",