@riocrypto/common-server 1.0.509 → 1.0.510

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.
@@ -20,6 +20,7 @@ declare global {
20
20
  currentAdminAuth?: AdminAuthPayload;
21
21
  user?: UserDoc | BusinessUserDoc;
22
22
  partner?: PartnerDoc;
23
+ validAdminApiKey?: boolean;
23
24
  session?: any;
24
25
  }
25
26
  }
@@ -30,6 +30,12 @@ const partner_1 = require("../models/partner");
30
30
  const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(void 0, void 0, void 0, function* () {
31
31
  var _a, _b, _c, _d, _e, _f, _g, _h;
32
32
  let missingKYC = false;
33
+ if (authorizationTypes.includes(authorization_type_1.AuthorizationType.AdminAPI)) {
34
+ let apiKey = req.header("x-api-key");
35
+ if (apiKey === process.env.ORIGINAL_ADMIN_API_KEY) {
36
+ req.validAdminApiKey = true;
37
+ }
38
+ }
33
39
  if (authorizationTypes.includes(authorization_type_1.AuthorizationType.Auth) ||
34
40
  authorizationTypes.includes(authorization_type_1.AuthorizationType.UserNoKYC) ||
35
41
  authorizationTypes.includes(authorization_type_1.AuthorizationType.User) ||
@@ -163,7 +169,11 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
163
169
  }
164
170
  if (
165
171
  // if no auth
166
- (!req.currentAdminAuth && !req.currentAuth && !req.user && !req.partner) ||
172
+ (!req.currentAdminAuth &&
173
+ !req.currentAuth &&
174
+ !req.user &&
175
+ !req.partner &&
176
+ !req.validAdminApiKey) ||
167
177
  (!req.currentAuth &&
168
178
  !authorizationTypes.includes(authorization_type_1.AuthorizationType.Auth) &&
169
179
  !req.user)) {
@@ -38,6 +38,7 @@ const buildAdminAuth = (mongoose) => {
38
38
  delete ret._id;
39
39
  delete ret.__v;
40
40
  delete ret.password;
41
+ delete ret.previousPasswords;
41
42
  },
42
43
  },
43
44
  });
@@ -4,5 +4,6 @@ export declare enum AuthorizationType {
4
4
  Broker = "broker",
5
5
  Admin = "admin",
6
6
  Partner = "partner",
7
- Auth = "auth"
7
+ Auth = "auth",
8
+ AdminAPI = "adminAPI"
8
9
  }
@@ -9,4 +9,5 @@ var AuthorizationType;
9
9
  AuthorizationType["Admin"] = "admin";
10
10
  AuthorizationType["Partner"] = "partner";
11
11
  AuthorizationType["Auth"] = "auth";
12
+ AuthorizationType["AdminAPI"] = "adminAPI";
12
13
  })(AuthorizationType = exports.AuthorizationType || (exports.AuthorizationType = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.509",
3
+ "version": "1.0.510",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",