@riocrypto/common-server 1.0.1820 → 1.0.1821
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.
|
@@ -22,8 +22,7 @@ const secret_manager_client_1 = require("../clients/secret-manager-client");
|
|
|
22
22
|
const admin_auth_1 = require("../models/admin-auth");
|
|
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
|
-
if (authorizationTypes.includes(common_1.AuthorizationType.GenesisAdmin)
|
|
26
|
-
req.header("x-genesis-api-key")) {
|
|
25
|
+
if (authorizationTypes.includes(common_1.AuthorizationType.GenesisAdmin)) {
|
|
27
26
|
let apiKey = req.header("x-genesis-api-key");
|
|
28
27
|
const GENESIS_ADMIN_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("GENESIS_ADMIN_KEY");
|
|
29
28
|
if (!GENESIS_ADMIN_KEY) {
|
|
@@ -33,8 +32,7 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
33
32
|
req.validGenisisAdminKey = true;
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
|
-
if (authorizationTypes.includes(common_1.AuthorizationType.Cluster)
|
|
37
|
-
req.header("x-cluster-api-key")) {
|
|
35
|
+
if (authorizationTypes.includes(common_1.AuthorizationType.Cluster)) {
|
|
38
36
|
let apiKey = req.header("x-cluster-api-key");
|
|
39
37
|
const CLUSTER_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("CLUSTER_API_KEY");
|
|
40
38
|
if (!CLUSTER_API_KEY) {
|
|
@@ -44,8 +42,7 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
44
42
|
req.validClusterApiKey = true;
|
|
45
43
|
}
|
|
46
44
|
}
|
|
47
|
-
if (authorizationTypes.includes(common_1.AuthorizationType.AdminAuth)
|
|
48
|
-
req.header("x-admin-api-key")) {
|
|
45
|
+
if (authorizationTypes.includes(common_1.AuthorizationType.AdminAuth)) {
|
|
49
46
|
const adminApiKey = req.header("x-admin-api-key");
|
|
50
47
|
const AdminAuth = yield (0, admin_auth_1.buildAdminAuth)(mongoose);
|
|
51
48
|
if (adminApiKey) {
|
|
@@ -81,8 +78,8 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
81
78
|
authorizationTypes.includes(common_1.AuthorizationType.UserNoKYC) ||
|
|
82
79
|
authorizationTypes.includes(common_1.AuthorizationType.User)) {
|
|
83
80
|
const apiKey = req.header("x-api-key");
|
|
81
|
+
const Auth = yield (0, auth_1.buildAuth)(mongoose);
|
|
84
82
|
if (apiKey) {
|
|
85
|
-
const Auth = yield (0, auth_1.buildAuth)(mongoose);
|
|
86
83
|
try {
|
|
87
84
|
const hashedApiKey = yield apiKey_1.ApiKey.toHash(apiKey);
|
|
88
85
|
const auth = yield Auth.findOne({
|
|
@@ -95,7 +92,6 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
95
92
|
catch (err) { }
|
|
96
93
|
}
|
|
97
94
|
else if ((_b = req.cookies) === null || _b === void 0 ? void 0 : _b.accessToken) {
|
|
98
|
-
const Auth = yield (0, auth_1.buildAuth)(mongoose);
|
|
99
95
|
try {
|
|
100
96
|
const ACCESS_TOKEN_SECRET = yield secret_manager_client_1.secretManagerClient.getSecretValue("ACCESS_TOKEN_SECRET");
|
|
101
97
|
if (!ACCESS_TOKEN_SECRET) {
|