@riocrypto/common-server 1.0.518 → 1.0.520

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.
@@ -30,6 +30,7 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
30
30
  if (authorizationTypes.includes(common_1.AuthorizationType.Auth) ||
31
31
  authorizationTypes.includes(common_1.AuthorizationType.UserNoKYC) ||
32
32
  authorizationTypes.includes(common_1.AuthorizationType.User) ||
33
+ authorizationTypes.includes(common_1.AuthorizationType.UserOptional) ||
33
34
  authorizationTypes.includes(common_1.AuthorizationType.Broker) ||
34
35
  authorizationTypes.includes(common_1.AuthorizationType.Partner)) {
35
36
  if ((_a = req.cookies) === null || _a === void 0 ? void 0 : _a.jwt) {
@@ -39,11 +40,13 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
39
40
  }
40
41
  catch (err) { }
41
42
  }
42
- if ((_c = (_b = req.currentAuth) === null || _b === void 0 ? void 0 : _b.missing) === null || _c === void 0 ? void 0 : _c.includes("password")) {
43
- throw new common_1.MissingPasswordError();
44
- }
45
- if ((_e = (_d = req.currentAuth) === null || _d === void 0 ? void 0 : _d.missing) === null || _e === void 0 ? void 0 : _e.includes("securityQuestion")) {
46
- throw new common_1.MissingSecurityQuestionError();
43
+ if (!authorizationTypes.includes(common_1.AuthorizationType.UserOptional)) {
44
+ if ((_c = (_b = req.currentAuth) === null || _b === void 0 ? void 0 : _b.missing) === null || _c === void 0 ? void 0 : _c.includes("password")) {
45
+ throw new common_1.MissingPasswordError();
46
+ }
47
+ if ((_e = (_d = req.currentAuth) === null || _d === void 0 ? void 0 : _d.missing) === null || _e === void 0 ? void 0 : _e.includes("securityQuestion")) {
48
+ throw new common_1.MissingSecurityQuestionError();
49
+ }
47
50
  }
48
51
  }
49
52
  if (authorizationTypes.includes(common_1.AuthorizationType.Admin)) {
@@ -93,7 +96,8 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
93
96
  req.user = user;
94
97
  }
95
98
  }
96
- if (authorizationTypes.includes(common_1.AuthorizationType.User)) {
99
+ if (authorizationTypes.includes(common_1.AuthorizationType.User) ||
100
+ authorizationTypes.includes(common_1.AuthorizationType.UserOptional)) {
97
101
  let individualUser;
98
102
  let businessUser;
99
103
  try {
@@ -169,6 +173,11 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
169
173
  !authorizationTypes.includes(common_1.AuthorizationType.Auth) &&
170
174
  !req.user &&
171
175
  !req.validAdminApiKey)) {
176
+ if (!req.user &&
177
+ authorizationTypes.includes(common_1.AuthorizationType.UserOptional)) {
178
+ next();
179
+ return;
180
+ }
172
181
  if (req.currentAdminAuth &&
173
182
  authorizationTypes.includes(common_1.AuthorizationType.Admin)) {
174
183
  next();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.518",
3
+ "version": "1.0.520",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@aws-sdk/client-s3": "^3.297.0",
25
- "@riocrypto/common": "^1.0.526",
25
+ "@riocrypto/common": "^1.0.527",
26
26
  "@types/express": "^4.17.13",
27
27
  "axios": "^0.27.2",
28
28
  "ccxt": "^3.0.30",