@riocrypto/common-server 1.0.691 → 1.0.693

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.
@@ -23,7 +23,6 @@ const secret_manager_client_1 = require("../clients/secret-manager-client");
23
23
  const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(void 0, void 0, void 0, function* () {
24
24
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
25
25
  const apiKey = req.header("x-api-key");
26
- console.log("x-api-key is ", apiKey);
27
26
  let missingKYC = false;
28
27
  if (authorizationTypes.includes(common_1.AuthorizationType.AdminAPI)) {
29
28
  let apiKey = req.header("x-api-key");
@@ -100,9 +99,12 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
100
99
  throw new Error("Unable to get ADMIN_ACCESS_TOKEN_SECRET");
101
100
  }
102
101
  const payload = jsonwebtoken_1.default.verify(req.cookies.adminAccessToken, ADMIN_ACCESS_TOKEN_SECRET);
102
+ console.log(payload);
103
103
  req.currentAdminAuth = payload;
104
104
  }
105
- catch (err) { }
105
+ catch (err) {
106
+ console.log(err);
107
+ }
106
108
  }
107
109
  }
108
110
  if (authorizationTypes.includes(common_1.AuthorizationType.PartnerAuth) ||
@@ -211,6 +213,9 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
211
213
  !req.validAdminApiKey &&
212
214
  !req.currentPartnerAuth &&
213
215
  !authorizationTypes.includes(common_1.AuthorizationType.Public))) {
216
+ console.log("missing auth");
217
+ console.log("currentAdminAuth, ", req.currentAdminAuth);
218
+ console.log(authorizationTypes);
214
219
  if (!req.user &&
215
220
  authorizationTypes.includes(common_1.AuthorizationType.UserOptional)) {
216
221
  next();
@@ -218,12 +223,14 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
218
223
  }
219
224
  if (req.currentAdminAuth &&
220
225
  authorizationTypes.includes(common_1.AuthorizationType.Admin)) {
226
+ console.log("safe");
221
227
  next();
222
228
  return;
223
229
  }
224
230
  if (missingKYC) {
225
231
  throw new common_1.MissingKYCApprovalError();
226
232
  }
233
+ console.log("not safe");
227
234
  if ((authorizationTypes.includes(common_1.AuthorizationType.User) ||
228
235
  authorizationTypes.includes(common_1.AuthorizationType.UserNoKYC)) &&
229
236
  ((_h = req.cookies) === null || _h === void 0 ? void 0 : _h.accessToken)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.691",
3
+ "version": "1.0.693",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",