@riocrypto/common-server 1.0.548 → 1.0.556
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.
- package/build/common/src/types/rio-env.d.ts +6 -0
- package/build/common/src/types/rio-env.js +10 -0
- package/build/{clients → common-server/src/clients}/bitstamp-client.d.ts +1 -1
- package/build/{clients → common-server/src/clients}/bitstamp-client.js +13 -1
- package/build/{clients → common-server/src/clients}/ccxt-client.js +21 -4
- package/build/{clients → common-server/src/clients}/etherscan-client.js +6 -1
- package/build/{clients → common-server/src/clients}/fireblocks-client.d.ts +1 -1
- package/build/{clients → common-server/src/clients}/fireblocks-client.js +13 -1
- package/build/{clients → common-server/src/clients}/fixer-client.d.ts +1 -1
- package/build/{clients → common-server/src/clients}/fixer-client.js +10 -1
- package/build/{clients → common-server/src/clients}/gueno-client.d.ts +1 -1
- package/build/{clients → common-server/src/clients}/gueno-client.js +14 -1
- package/build/{clients → common-server/src/clients}/kushki-client.d.ts +1 -1
- package/build/{clients → common-server/src/clients}/kushki-client.js +10 -1
- package/build/common-server/src/clients/s3-client.d.ts +6 -0
- package/build/common-server/src/clients/s3-client.js +50 -0
- package/build/common-server/src/clients/secret-manager-client.d.ts +11 -0
- package/build/common-server/src/clients/secret-manager-client.js +90 -0
- package/build/{index.d.ts → common-server/src/index.d.ts} +2 -1
- package/build/{index.js → common-server/src/index.js} +2 -1
- package/build/{middlewares → common-server/src/middlewares}/authorize.js +16 -3
- package/build/{middlewares → common-server/src/middlewares}/current-admin-auth.d.ts +1 -1
- package/build/common-server/src/middlewares/current-admin-auth.js +34 -0
- package/build/{middlewares → common-server/src/middlewares}/current-auth.d.ts +1 -1
- package/build/common-server/src/middlewares/current-auth.js +34 -0
- package/build/{middlewares → common-server/src/middlewares}/get-partner.js +6 -1
- package/build/{middlewares → common-server/src/middlewares}/verify-admin-api-key.d.ts +1 -1
- package/build/common-server/src/middlewares/verify-admin-api-key.js +25 -0
- package/build/{services → common-server/src/services}/apiKey.js +6 -1
- package/package.json +2 -2
- package/build/middlewares/current-admin-auth.js +0 -20
- package/build/middlewares/current-auth.js +0 -20
- package/build/middlewares/verify-admin-api-key.js +0 -11
- package/build/services/s3.d.ts +0 -5
- package/build/services/s3.js +0 -21
- /package/build/{clients → common-server/src/clients}/ccxt-client.d.ts +0 -0
- /package/build/{clients → common-server/src/clients}/etherscan-client.d.ts +0 -0
- /package/build/{clients → common-server/src/clients}/kapstar-client.d.ts +0 -0
- /package/build/{clients → common-server/src/clients}/kapstar-client.js +0 -0
- /package/build/{clients → common-server/src/clients}/rio-client.d.ts +0 -0
- /package/build/{clients → common-server/src/clients}/rio-client.js +0 -0
- /package/build/{clients → common-server/src/clients}/slack-client.d.ts +0 -0
- /package/build/{clients → common-server/src/clients}/slack-client.js +0 -0
- /package/build/{helpers → common-server/src/helpers}/get-user-helper.d.ts +0 -0
- /package/build/{helpers → common-server/src/helpers}/get-user-helper.js +0 -0
- /package/build/{middlewares → common-server/src/middlewares}/authorize.d.ts +0 -0
- /package/build/{middlewares → common-server/src/middlewares}/error-handler.d.ts +0 -0
- /package/build/{middlewares → common-server/src/middlewares}/error-handler.js +0 -0
- /package/build/{middlewares → common-server/src/middlewares}/get-order.d.ts +0 -0
- /package/build/{middlewares → common-server/src/middlewares}/get-order.js +0 -0
- /package/build/{middlewares → common-server/src/middlewares}/get-partner.d.ts +0 -0
- /package/build/{middlewares → common-server/src/middlewares}/get-user.d.ts +0 -0
- /package/build/{middlewares → common-server/src/middlewares}/get-user.js +0 -0
- /package/build/{middlewares → common-server/src/middlewares}/require-admin-api-key.d.ts +0 -0
- /package/build/{middlewares → common-server/src/middlewares}/require-admin-api-key.js +0 -0
- /package/build/{middlewares → common-server/src/middlewares}/require-auth.d.ts +0 -0
- /package/build/{middlewares → common-server/src/middlewares}/require-auth.js +0 -0
- /package/build/{middlewares → common-server/src/middlewares}/require-priveleges.d.ts +0 -0
- /package/build/{middlewares → common-server/src/middlewares}/require-priveleges.js +0 -0
- /package/build/{middlewares → common-server/src/middlewares}/validate-auth.d.ts +0 -0
- /package/build/{middlewares → common-server/src/middlewares}/validate-auth.js +0 -0
- /package/build/{middlewares → common-server/src/middlewares}/validate-kyc.d.ts +0 -0
- /package/build/{middlewares → common-server/src/middlewares}/validate-kyc.js +0 -0
- /package/build/{middlewares → common-server/src/middlewares}/validate-order.d.ts +0 -0
- /package/build/{middlewares → common-server/src/middlewares}/validate-order.js +0 -0
- /package/build/{middlewares → common-server/src/middlewares}/validate-request.d.ts +0 -0
- /package/build/{middlewares → common-server/src/middlewares}/validate-request.js +0 -0
- /package/build/{models → common-server/src/models}/admin-auth.d.ts +0 -0
- /package/build/{models → common-server/src/models}/admin-auth.js +0 -0
- /package/build/{models → common-server/src/models}/auth.d.ts +0 -0
- /package/build/{models → common-server/src/models}/auth.js +0 -0
- /package/build/{models → common-server/src/models}/bank-payment.d.ts +0 -0
- /package/build/{models → common-server/src/models}/bank-payment.js +0 -0
- /package/build/{models → common-server/src/models}/bank-payout.d.ts +0 -0
- /package/build/{models → common-server/src/models}/bank-payout.js +0 -0
- /package/build/{models → common-server/src/models}/business-user.d.ts +0 -0
- /package/build/{models → common-server/src/models}/business-user.js +0 -0
- /package/build/{models → common-server/src/models}/ccxt-order.d.ts +0 -0
- /package/build/{models → common-server/src/models}/ccxt-order.js +0 -0
- /package/build/{models → common-server/src/models}/checked-address.d.ts +0 -0
- /package/build/{models → common-server/src/models}/checked-address.js +0 -0
- /package/build/{models → common-server/src/models}/kushki-payment.d.ts +0 -0
- /package/build/{models → common-server/src/models}/kushki-payment.js +0 -0
- /package/build/{models → common-server/src/models}/kyc.d.ts +0 -0
- /package/build/{models → common-server/src/models}/kyc.js +0 -0
- /package/build/{models → common-server/src/models}/order.d.ts +0 -0
- /package/build/{models → common-server/src/models}/order.js +0 -0
- /package/build/{models → common-server/src/models}/partner.d.ts +0 -0
- /package/build/{models → common-server/src/models}/partner.js +0 -0
- /package/build/{models → common-server/src/models}/rio-settings.d.ts +0 -0
- /package/build/{models → common-server/src/models}/rio-settings.js +0 -0
- /package/build/{models → common-server/src/models}/user.d.ts +0 -0
- /package/build/{models → common-server/src/models}/user.js +0 -0
- /package/build/{services → common-server/src/services}/apiKey.d.ts +0 -0
- /package/build/{services → common-server/src/services}/password.d.ts +0 -0
- /package/build/{services → common-server/src/services}/password.js +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RioEnv = void 0;
|
|
4
|
+
var RioEnv;
|
|
5
|
+
(function (RioEnv) {
|
|
6
|
+
RioEnv["Development"] = "development";
|
|
7
|
+
RioEnv["Sandbox"] = "sandbox";
|
|
8
|
+
RioEnv["Staging"] = "staging";
|
|
9
|
+
RioEnv["Production"] = "production";
|
|
10
|
+
})(RioEnv = exports.RioEnv || (exports.RioEnv = {}));
|
|
@@ -39,6 +39,7 @@ exports.bitstampClient = void 0;
|
|
|
39
39
|
const axios_1 = __importDefault(require("axios"));
|
|
40
40
|
const crypto = __importStar(require("crypto"));
|
|
41
41
|
const uuid = __importStar(require("uuid"));
|
|
42
|
+
const secret_manager_client_1 = require("./secret-manager-client");
|
|
42
43
|
class BitstampClient {
|
|
43
44
|
constructor(apiKey, apiSecret) {
|
|
44
45
|
this.apiKey = apiKey;
|
|
@@ -80,4 +81,15 @@ class BitstampClient {
|
|
|
80
81
|
});
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
|
-
exports.bitstampClient =
|
|
84
|
+
exports.bitstampClient = (() => __awaiter(void 0, void 0, void 0, function* () {
|
|
85
|
+
const BITSTAMP_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("BITSTAMP_API_KEY");
|
|
86
|
+
if (!BITSTAMP_API_KEY) {
|
|
87
|
+
throw new Error("Unable to get BITSTAMP_API_KEY");
|
|
88
|
+
}
|
|
89
|
+
const BITSTAMP_SECRET = yield secret_manager_client_1.secretManagerClient.getSecretValue("BITSTAMP_SECRET");
|
|
90
|
+
if (!BITSTAMP_SECRET) {
|
|
91
|
+
throw new Error("Unable to get BITSTAMP_SECRET");
|
|
92
|
+
}
|
|
93
|
+
const bitstampClient = new BitstampClient(BITSTAMP_API_KEY, BITSTAMP_SECRET);
|
|
94
|
+
return bitstampClient;
|
|
95
|
+
}))();
|
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.ccxtWrapper = void 0;
|
|
16
16
|
const common_1 = require("@riocrypto/common");
|
|
17
17
|
const ccxt_1 = __importDefault(require("ccxt"));
|
|
18
|
+
const secret_manager_client_1 = require("./secret-manager-client");
|
|
18
19
|
class CCXTClient {
|
|
19
20
|
constructor(env) {
|
|
20
21
|
this.env = env;
|
|
@@ -123,10 +124,18 @@ class CCXTClient {
|
|
|
123
124
|
return __awaiter(this, void 0, void 0, function* () {
|
|
124
125
|
for (let exchangeId of ccxt_1.default.exchanges) {
|
|
125
126
|
if (exchangeId === "bitstamp") {
|
|
127
|
+
const SECRET = yield secret_manager_client_1.secretManagerClient.getSecretValue(`${exchangeId.toLocaleUpperCase()}_SECRET`);
|
|
128
|
+
if (!SECRET) {
|
|
129
|
+
throw new Error("Unable to get SECRET");
|
|
130
|
+
}
|
|
131
|
+
const API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue(`${exchangeId.toLocaleUpperCase()}_API_KEY`);
|
|
132
|
+
if (!API_KEY) {
|
|
133
|
+
throw new Error("Unable to get API_KEY");
|
|
134
|
+
}
|
|
126
135
|
//@ts-ignore
|
|
127
136
|
const exchangeClass = ccxt_1.default[exchangeId], exchange = new exchangeClass({
|
|
128
|
-
apiKey:
|
|
129
|
-
secret:
|
|
137
|
+
apiKey: API_KEY,
|
|
138
|
+
secret: SECRET,
|
|
130
139
|
});
|
|
131
140
|
return exchange;
|
|
132
141
|
}
|
|
@@ -146,10 +155,18 @@ class CCXTClient {
|
|
|
146
155
|
}
|
|
147
156
|
getExchange(ccxtLiquidityProvider) {
|
|
148
157
|
return __awaiter(this, void 0, void 0, function* () {
|
|
158
|
+
const SECRET = yield secret_manager_client_1.secretManagerClient.getSecretValue(`${ccxtLiquidityProvider.toLocaleUpperCase()}_SECRET`);
|
|
159
|
+
if (!SECRET) {
|
|
160
|
+
throw new Error("Unable to get SECRET");
|
|
161
|
+
}
|
|
162
|
+
const API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue(`${ccxtLiquidityProvider.toLocaleUpperCase()}_API_KEY`);
|
|
163
|
+
if (!API_KEY) {
|
|
164
|
+
throw new Error("Unable to get API_KEY");
|
|
165
|
+
}
|
|
149
166
|
// @ts-ignore
|
|
150
167
|
const exchangeClass = ccxt_1.default[ccxtLiquidityProvider], exchange = new exchangeClass({
|
|
151
|
-
apiKey:
|
|
152
|
-
secret:
|
|
168
|
+
apiKey: API_KEY,
|
|
169
|
+
secret: SECRET,
|
|
153
170
|
});
|
|
154
171
|
return exchange;
|
|
155
172
|
});
|
|
@@ -10,13 +10,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.EtherscanClient = void 0;
|
|
13
|
+
const secret_manager_client_1 = require("./secret-manager-client");
|
|
13
14
|
class EtherscanClient {
|
|
14
15
|
constructor(axios) {
|
|
15
16
|
this.axios = axios;
|
|
16
17
|
}
|
|
17
18
|
getTransactions(address) {
|
|
18
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
const
|
|
20
|
+
const ETHERSCAN_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("ETHERSCAN_API_KEY");
|
|
21
|
+
if (!ETHERSCAN_API_KEY) {
|
|
22
|
+
throw new Error("Unable to get ETHERSCAN_API_KEY");
|
|
23
|
+
}
|
|
24
|
+
const { data } = yield this.axios.get(`https://api.etherscan.io/api?module=account&action=txlist&address=${address}&startblock=0&endblock=99999999&page=1&offset=100&sort=asc&apikey=${ETHERSCAN_API_KEY}`);
|
|
20
25
|
return data.result;
|
|
21
26
|
});
|
|
22
27
|
}
|
|
@@ -13,5 +13,5 @@ declare class FireblocksClient {
|
|
|
13
13
|
getTransactions(crypto: Crypto): Promise<any>;
|
|
14
14
|
getDepositAddress(crypto: Crypto): Promise<string>;
|
|
15
15
|
}
|
|
16
|
-
export declare const fireblocksClient: FireblocksClient
|
|
16
|
+
export declare const fireblocksClient: Promise<FireblocksClient>;
|
|
17
17
|
export {};
|
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.fireblocksClient = void 0;
|
|
13
13
|
const fireblocks_sdk_1 = require("fireblocks-sdk");
|
|
14
|
+
const secret_manager_client_1 = require("./secret-manager-client");
|
|
14
15
|
class FireblocksClient {
|
|
15
16
|
constructor(privateKey, apiKey) {
|
|
16
17
|
this.fireblocks = new fireblocks_sdk_1.FireblocksSDK(privateKey, apiKey, "https://api.fireblocks.io");
|
|
@@ -142,4 +143,15 @@ class FireblocksClient {
|
|
|
142
143
|
});
|
|
143
144
|
}
|
|
144
145
|
}
|
|
145
|
-
exports.fireblocksClient =
|
|
146
|
+
exports.fireblocksClient = (() => __awaiter(void 0, void 0, void 0, function* () {
|
|
147
|
+
const FIREBLOCKS_PRIVATE_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("FIREBLOCKS_PRIVATE_KEY");
|
|
148
|
+
if (!FIREBLOCKS_PRIVATE_KEY) {
|
|
149
|
+
throw new Error("Unable to get FIREBLOCKS_PRIVATE_KEY");
|
|
150
|
+
}
|
|
151
|
+
const FIREBLOCKS_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("FIREBLOCKS_API_KEY");
|
|
152
|
+
if (!FIREBLOCKS_API_KEY) {
|
|
153
|
+
throw new Error("Unable to get FIREBLOCKS_API_KEY");
|
|
154
|
+
}
|
|
155
|
+
const fireblocksClient = new FireblocksClient(FIREBLOCKS_PRIVATE_KEY, FIREBLOCKS_API_KEY);
|
|
156
|
+
return fireblocksClient;
|
|
157
|
+
}))();
|
|
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.fixerClient = void 0;
|
|
16
16
|
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
const secret_manager_client_1 = require("./secret-manager-client");
|
|
17
18
|
class FixerClient {
|
|
18
19
|
constructor(apiKey) {
|
|
19
20
|
this.apiKey = apiKey;
|
|
@@ -31,4 +32,12 @@ class FixerClient {
|
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
|
-
exports.fixerClient =
|
|
35
|
+
exports.fixerClient = (() => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
// Retrieve secret asynchronously
|
|
37
|
+
const FIXER_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("FIXER_API_KEY");
|
|
38
|
+
if (!FIXER_API_KEY) {
|
|
39
|
+
throw new Error("Unable to get FIXER_API_KEY");
|
|
40
|
+
}
|
|
41
|
+
// Create FixerClient instance and return
|
|
42
|
+
return new FixerClient(FIXER_API_KEY);
|
|
43
|
+
}))();
|
|
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.guenoClient = void 0;
|
|
16
|
+
const secret_manager_client_1 = require("./secret-manager-client");
|
|
16
17
|
const axios_1 = __importDefault(require("axios"));
|
|
17
18
|
class GuenoClient {
|
|
18
19
|
constructor(email, password, env) {
|
|
@@ -41,4 +42,16 @@ class GuenoClient {
|
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
|
-
exports.guenoClient =
|
|
45
|
+
exports.guenoClient = (() => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
+
// Retrieve secrets asynchronously
|
|
47
|
+
const GUENO_EMAIL = yield secret_manager_client_1.secretManagerClient.getSecretValue("GUENO_EMAIL");
|
|
48
|
+
if (!GUENO_EMAIL) {
|
|
49
|
+
throw new Error("Unable to get GUENO_EMAIL");
|
|
50
|
+
}
|
|
51
|
+
const GUENO_PASSWORD = yield secret_manager_client_1.secretManagerClient.getSecretValue("GUENO_PASSWORD");
|
|
52
|
+
if (!GUENO_PASSWORD) {
|
|
53
|
+
throw new Error("Unable to get GUENO_PASSWORD");
|
|
54
|
+
}
|
|
55
|
+
// Create GuenoClient instance and return
|
|
56
|
+
return new GuenoClient(GUENO_EMAIL, GUENO_PASSWORD, process.env.GUENO_ENV);
|
|
57
|
+
}))();
|
|
@@ -8,5 +8,5 @@ declare class KushkiClient {
|
|
|
8
8
|
createBankPaymentToken(order: Order, user: User | BusinessUser): Promise<any>;
|
|
9
9
|
createBankPayment(order: Order, user: User | BusinessUser, token: string): Promise<any>;
|
|
10
10
|
}
|
|
11
|
-
export declare const kushkiClient: KushkiClient
|
|
11
|
+
export declare const kushkiClient: Promise<KushkiClient>;
|
|
12
12
|
export {};
|
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.kushkiClient = void 0;
|
|
16
16
|
const common_1 = require("@riocrypto/common");
|
|
17
17
|
const axios_1 = __importDefault(require("axios"));
|
|
18
|
+
const secret_manager_client_1 = require("./secret-manager-client");
|
|
18
19
|
class KushkiClient {
|
|
19
20
|
constructor(privateMerchantId, environment) {
|
|
20
21
|
this.privateMerchantId = privateMerchantId;
|
|
@@ -147,4 +148,12 @@ class KushkiClient {
|
|
|
147
148
|
});
|
|
148
149
|
}
|
|
149
150
|
}
|
|
150
|
-
|
|
151
|
+
const createKushkiClient = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
152
|
+
const KUSHKI_PRIVATE_MERCHANT_ID = yield secret_manager_client_1.secretManagerClient.getSecretValue("KUSHKI_PRIVATE_MERCHANT_ID");
|
|
153
|
+
if (!KUSHKI_PRIVATE_MERCHANT_ID) {
|
|
154
|
+
throw new Error("Unable to get KUSHKI_PRIVATE_MERCHANT_ID");
|
|
155
|
+
}
|
|
156
|
+
const kushkiClient = new KushkiClient(KUSHKI_PRIVATE_MERCHANT_ID, process.env.KUSHKI_ENV);
|
|
157
|
+
return kushkiClient;
|
|
158
|
+
});
|
|
159
|
+
exports.kushkiClient = createKushkiClient();
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.s3Client = exports.s3 = void 0;
|
|
13
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
14
|
+
const secret_manager_client_1 = require("./secret-manager-client");
|
|
15
|
+
class s3 {
|
|
16
|
+
constructor(endpoint, region, accessKey, secretKey) {
|
|
17
|
+
this._client = new client_s3_1.S3Client({
|
|
18
|
+
endpoint,
|
|
19
|
+
forcePathStyle: false,
|
|
20
|
+
region,
|
|
21
|
+
credentials: {
|
|
22
|
+
accessKeyId: accessKey,
|
|
23
|
+
secretAccessKey: secretKey, // Secret access key defined through an environment variable.
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
get client() {
|
|
28
|
+
return this._client;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.s3 = s3;
|
|
32
|
+
exports.s3Client = (() => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
+
const S3_ENDPOINT = yield secret_manager_client_1.secretManagerClient.getSecretValue("S3_ENDPOINT");
|
|
34
|
+
if (!S3_ENDPOINT) {
|
|
35
|
+
throw new Error("Unable to get S3_ENDPOINT");
|
|
36
|
+
}
|
|
37
|
+
const S3_ACCESS_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("S3_ACCESS_KEY");
|
|
38
|
+
if (!S3_ACCESS_KEY) {
|
|
39
|
+
throw new Error("Unable to get S3_ACCESS_KEY");
|
|
40
|
+
}
|
|
41
|
+
const S3_SECRET_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("S3_SECRET_KEY");
|
|
42
|
+
if (!S3_SECRET_KEY) {
|
|
43
|
+
throw new Error("Unable to get S3_SECRET_KEY");
|
|
44
|
+
}
|
|
45
|
+
const S3_REGION = yield secret_manager_client_1.secretManagerClient.getSecretValue("S3_REGION");
|
|
46
|
+
if (!S3_REGION) {
|
|
47
|
+
throw new Error("Unable to get S3_REGION");
|
|
48
|
+
}
|
|
49
|
+
return new s3(S3_ENDPOINT, S3_REGION, S3_ACCESS_KEY, S3_SECRET_KEY);
|
|
50
|
+
}))();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SecretManagerServiceClient } from "@google-cloud/secret-manager";
|
|
2
|
+
import { RioEnv } from "../../../common/src/types/rio-env";
|
|
3
|
+
declare class SecretManagerClient {
|
|
4
|
+
private env;
|
|
5
|
+
client: SecretManagerServiceClient;
|
|
6
|
+
projectId: string;
|
|
7
|
+
constructor(env: RioEnv);
|
|
8
|
+
getSecretValue(secretId: string): Promise<string | null>;
|
|
9
|
+
}
|
|
10
|
+
export declare const secretManagerClient: SecretManagerClient;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.secretManagerClient = void 0;
|
|
36
|
+
const secret_manager_1 = require("@google-cloud/secret-manager");
|
|
37
|
+
const rio_env_1 = require("../../../common/src/types/rio-env");
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
class SecretManagerClient {
|
|
40
|
+
constructor(env) {
|
|
41
|
+
this.env = env;
|
|
42
|
+
const secretFilePath = "/etc/secrets/secret-manager-service-account-key.json";
|
|
43
|
+
const secretFileContents = fs.readFileSync(secretFilePath, "utf8");
|
|
44
|
+
const secretData = JSON.parse(secretFileContents);
|
|
45
|
+
this.projectId = secretData.project_id;
|
|
46
|
+
const clientEmail = secretData.client_email;
|
|
47
|
+
const privateKey = secretData.private_key;
|
|
48
|
+
this.client = new secret_manager_1.SecretManagerServiceClient({
|
|
49
|
+
projectId: this.projectId,
|
|
50
|
+
credentials: {
|
|
51
|
+
client_email: clientEmail,
|
|
52
|
+
private_key: privateKey,
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
getSecretValue(secretId) {
|
|
57
|
+
var _a, _b, _c, _d;
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
let file;
|
|
60
|
+
if (this.env === rio_env_1.RioEnv.Development) {
|
|
61
|
+
file = "dev-secrets";
|
|
62
|
+
}
|
|
63
|
+
else if (this.env === rio_env_1.RioEnv.Sandbox) {
|
|
64
|
+
file = "sandbox-secrets";
|
|
65
|
+
}
|
|
66
|
+
else if (this.env === rio_env_1.RioEnv.Staging) {
|
|
67
|
+
file = "staging-secrets";
|
|
68
|
+
}
|
|
69
|
+
else if (this.env === rio_env_1.RioEnv.Production) {
|
|
70
|
+
file = "production-secrets";
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
// Access the secret version
|
|
74
|
+
const [version] = yield this.client.accessSecretVersion({
|
|
75
|
+
name: `projects/${this.projectId}/secrets/${file}/versions/latest`,
|
|
76
|
+
});
|
|
77
|
+
if (!((_b = (_a = version.payload) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.toString())) {
|
|
78
|
+
throw new Error();
|
|
79
|
+
}
|
|
80
|
+
const secrets = JSON.parse((_d = (_c = version.payload) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.toString());
|
|
81
|
+
return secrets[secretId];
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
console.error(`Failed to access secret ${secretId}: ${err}`);
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.secretManagerClient = new SecretManagerClient(process.env.RIO_ENV || process.env.NEXT_PUBLIC_RIO_ENV);
|
|
@@ -14,7 +14,6 @@ export * from "./middlewares/validate-kyc";
|
|
|
14
14
|
export * from "./middlewares/authorize";
|
|
15
15
|
export * from "./services/apiKey";
|
|
16
16
|
export * from "./services/password";
|
|
17
|
-
export * from "./services/s3";
|
|
18
17
|
export * from "./models/admin-auth";
|
|
19
18
|
export * from "./models/auth";
|
|
20
19
|
export * from "./models/business-user";
|
|
@@ -38,4 +37,6 @@ export * from "./clients/fireblocks-client";
|
|
|
38
37
|
export * from "./clients/kapstar-client";
|
|
39
38
|
export * from "./clients/etherscan-client";
|
|
40
39
|
export * from "./clients/rio-client";
|
|
40
|
+
export * from "./clients/s3-client";
|
|
41
|
+
export * from "./clients/secret-manager-client";
|
|
41
42
|
export * from "./helpers/get-user-helper";
|
|
@@ -30,7 +30,6 @@ __exportStar(require("./middlewares/validate-kyc"), exports);
|
|
|
30
30
|
__exportStar(require("./middlewares/authorize"), exports);
|
|
31
31
|
__exportStar(require("./services/apiKey"), exports);
|
|
32
32
|
__exportStar(require("./services/password"), exports);
|
|
33
|
-
__exportStar(require("./services/s3"), exports);
|
|
34
33
|
__exportStar(require("./models/admin-auth"), exports);
|
|
35
34
|
__exportStar(require("./models/auth"), exports);
|
|
36
35
|
__exportStar(require("./models/business-user"), exports);
|
|
@@ -54,4 +53,6 @@ __exportStar(require("./clients/fireblocks-client"), exports);
|
|
|
54
53
|
__exportStar(require("./clients/kapstar-client"), exports);
|
|
55
54
|
__exportStar(require("./clients/etherscan-client"), exports);
|
|
56
55
|
__exportStar(require("./clients/rio-client"), exports);
|
|
56
|
+
__exportStar(require("./clients/s3-client"), exports);
|
|
57
|
+
__exportStar(require("./clients/secret-manager-client"), exports);
|
|
57
58
|
__exportStar(require("./helpers/get-user-helper"), exports);
|
|
@@ -20,12 +20,17 @@ const partner_1 = require("../models/partner");
|
|
|
20
20
|
const common_1 = require("@riocrypto/common");
|
|
21
21
|
const auth_1 = require("../models/auth");
|
|
22
22
|
const apiKey_1 = require("../services/apiKey");
|
|
23
|
+
const secret_manager_client_1 = require("../clients/secret-manager-client");
|
|
23
24
|
const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
25
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
25
26
|
let missingKYC = false;
|
|
26
27
|
if (authorizationTypes.includes(common_1.AuthorizationType.AdminAPI)) {
|
|
27
28
|
let apiKey = req.header("x-api-key");
|
|
28
|
-
|
|
29
|
+
const ADMIN_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("ADMIN_API_KEY");
|
|
30
|
+
if (!ADMIN_API_KEY) {
|
|
31
|
+
throw new Error("Unable to get ADMIN_API_KEY");
|
|
32
|
+
}
|
|
33
|
+
if (apiKey === ADMIN_API_KEY) {
|
|
29
34
|
req.validAdminApiKey = true;
|
|
30
35
|
}
|
|
31
36
|
}
|
|
@@ -63,7 +68,11 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
63
68
|
}
|
|
64
69
|
else if ((_a = req.cookies) === null || _a === void 0 ? void 0 : _a.accessToken) {
|
|
65
70
|
try {
|
|
66
|
-
const
|
|
71
|
+
const ACCESS_TOKEN_SECRET = yield secret_manager_client_1.secretManagerClient.getSecretValue("ACCESS_TOKEN_SECRET");
|
|
72
|
+
if (!ACCESS_TOKEN_SECRET) {
|
|
73
|
+
throw new Error("Unable to get ACCESS_TOKEN_SECRET");
|
|
74
|
+
}
|
|
75
|
+
const payload = jsonwebtoken_1.default.verify(req.cookies.accessToken, ACCESS_TOKEN_SECRET);
|
|
67
76
|
req.currentAuth = payload;
|
|
68
77
|
}
|
|
69
78
|
catch (err) { }
|
|
@@ -80,7 +89,11 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
80
89
|
if (authorizationTypes.includes(common_1.AuthorizationType.Admin)) {
|
|
81
90
|
if ((_f = req.cookies) === null || _f === void 0 ? void 0 : _f.adminAccessToken) {
|
|
82
91
|
try {
|
|
83
|
-
const
|
|
92
|
+
const ADMIN_ACCESS_TOKEN_SECRET = yield secret_manager_client_1.secretManagerClient.getSecretValue("ADMIN_ACCESS_TOKEN_SECRET");
|
|
93
|
+
if (!ADMIN_ACCESS_TOKEN_SECRET) {
|
|
94
|
+
throw new Error("Unable to get ADMIN_ACCESS_TOKEN_SECRET");
|
|
95
|
+
}
|
|
96
|
+
const payload = jsonwebtoken_1.default.verify(req.cookies.adminAccessToken, ADMIN_ACCESS_TOKEN_SECRET);
|
|
84
97
|
req.currentAdminAuth = payload;
|
|
85
98
|
}
|
|
86
99
|
catch (err) { }
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.currentAdminAuth = void 0;
|
|
16
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
17
|
+
const secret_manager_client_1 = require("../clients/secret-manager-client");
|
|
18
|
+
const currentAdminAuth = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
var _a;
|
|
20
|
+
if (!((_a = req.cookies) === null || _a === void 0 ? void 0 : _a.adminAccesToken)) {
|
|
21
|
+
return next();
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const ADMIN_ACCESS_TOKEN_SECRET = yield secret_manager_client_1.secretManagerClient.getSecretValue("ADMIN_ACCESS_TOKEN_SECRET");
|
|
25
|
+
if (!ADMIN_ACCESS_TOKEN_SECRET) {
|
|
26
|
+
throw new Error("ADMIN_ACCESS_TOKEN_SECRET");
|
|
27
|
+
}
|
|
28
|
+
const payload = jsonwebtoken_1.default.verify(req.cookies.adminAccesToken, ADMIN_ACCESS_TOKEN_SECRET);
|
|
29
|
+
req.currentAdminAuth = payload;
|
|
30
|
+
}
|
|
31
|
+
catch (err) { }
|
|
32
|
+
next();
|
|
33
|
+
});
|
|
34
|
+
exports.currentAdminAuth = currentAdminAuth;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.currentAuth = void 0;
|
|
16
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
17
|
+
const secret_manager_client_1 = require("../clients/secret-manager-client");
|
|
18
|
+
const currentAuth = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
var _a;
|
|
20
|
+
if (!((_a = req.cookies) === null || _a === void 0 ? void 0 : _a.accessToken)) {
|
|
21
|
+
return next();
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const ACCESS_TOKEN_SECRET = yield secret_manager_client_1.secretManagerClient.getSecretValue("ACCESS_TOKEN_SECRET");
|
|
25
|
+
if (!ACCESS_TOKEN_SECRET) {
|
|
26
|
+
throw new Error("Unable to get ACCESS_TOKEN_SECRET");
|
|
27
|
+
}
|
|
28
|
+
const payload = jsonwebtoken_1.default.verify(req.cookies.accessToken, ACCESS_TOKEN_SECRET);
|
|
29
|
+
req.currentAuth = payload;
|
|
30
|
+
}
|
|
31
|
+
catch (err) { }
|
|
32
|
+
next();
|
|
33
|
+
});
|
|
34
|
+
exports.currentAuth = currentAuth;
|
|
@@ -16,10 +16,15 @@ exports.getPartner = void 0;
|
|
|
16
16
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
17
17
|
const partner_1 = require("../models/partner");
|
|
18
18
|
const apiKey_1 = require("../services/apiKey");
|
|
19
|
+
const secret_manager_client_1 = require("../clients/secret-manager-client");
|
|
19
20
|
const getPartner = (req, res, next, mongoose) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
21
|
try {
|
|
21
22
|
if (!req.headers["x-api-key"]) {
|
|
22
|
-
const
|
|
23
|
+
const PARTNER_ACCESS_TOKEN_SECRET = yield secret_manager_client_1.secretManagerClient.getSecretValue("PARTNER_ACCESS_TOKEN_SECRET");
|
|
24
|
+
if (!PARTNER_ACCESS_TOKEN_SECRET) {
|
|
25
|
+
throw new Error("Unable to get PARTNER_ACCESS_TOKEN_SECRET");
|
|
26
|
+
}
|
|
27
|
+
const payload = jsonwebtoken_1.default.verify(req.cookies.partnerAuthJwt, PARTNER_ACCESS_TOKEN_SECRET);
|
|
23
28
|
req.partnerId = payload.partnerId;
|
|
24
29
|
}
|
|
25
30
|
else {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.verifyAdminApiKey = void 0;
|
|
13
|
+
const secret_manager_client_1 = require("../clients/secret-manager-client");
|
|
14
|
+
const verifyAdminApiKey = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
let apiKey = req.header("x-api-key");
|
|
16
|
+
const ADMIN_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("ADMIN_API_KEY");
|
|
17
|
+
if (!ADMIN_API_KEY) {
|
|
18
|
+
throw new Error("Unable to get ADMIN_API_KEY");
|
|
19
|
+
}
|
|
20
|
+
if (apiKey === ADMIN_API_KEY) {
|
|
21
|
+
req.validAdminApiKey = true;
|
|
22
|
+
}
|
|
23
|
+
next();
|
|
24
|
+
});
|
|
25
|
+
exports.verifyAdminApiKey = verifyAdminApiKey;
|
|
@@ -11,10 +11,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ApiKey = void 0;
|
|
13
13
|
const crypto_1 = require("crypto");
|
|
14
|
+
const secret_manager_client_1 = require("../clients/secret-manager-client");
|
|
14
15
|
class ApiKey {
|
|
15
16
|
static toHash(apiKey) {
|
|
16
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
const
|
|
18
|
+
const API_KEY_SALT = yield secret_manager_client_1.secretManagerClient.getSecretValue("API_KEY_SALT");
|
|
19
|
+
if (!API_KEY_SALT) {
|
|
20
|
+
throw new Error("Unable to get API_KEY_SALT");
|
|
21
|
+
}
|
|
22
|
+
const salt = API_KEY_SALT;
|
|
18
23
|
const hash = (0, crypto_1.createHmac)("sha256", salt);
|
|
19
24
|
hash.update(apiKey);
|
|
20
25
|
return hash.digest("hex");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.556",
|
|
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.
|
|
25
|
+
"@riocrypto/common": "^1.0.551",
|
|
26
26
|
"@types/express": "^4.17.13",
|
|
27
27
|
"axios": "^0.27.2",
|
|
28
28
|
"ccxt": "^3.0.30",
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.currentAdminAuth = void 0;
|
|
7
|
-
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
8
|
-
const currentAdminAuth = (req, res, next) => {
|
|
9
|
-
var _a;
|
|
10
|
-
if (!((_a = req.cookies) === null || _a === void 0 ? void 0 : _a.adminAccesToken)) {
|
|
11
|
-
return next();
|
|
12
|
-
}
|
|
13
|
-
try {
|
|
14
|
-
const payload = jsonwebtoken_1.default.verify(req.cookies.adminAccesToken, process.env.JWT_KEY_ADMIN);
|
|
15
|
-
req.currentAdminAuth = payload;
|
|
16
|
-
}
|
|
17
|
-
catch (err) { }
|
|
18
|
-
next();
|
|
19
|
-
};
|
|
20
|
-
exports.currentAdminAuth = currentAdminAuth;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.currentAuth = void 0;
|
|
7
|
-
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
8
|
-
const currentAuth = (req, res, next) => {
|
|
9
|
-
var _a;
|
|
10
|
-
if (!((_a = req.cookies) === null || _a === void 0 ? void 0 : _a.accessToken)) {
|
|
11
|
-
return next();
|
|
12
|
-
}
|
|
13
|
-
try {
|
|
14
|
-
const payload = jsonwebtoken_1.default.verify(req.cookies.accessToken, process.env.JWT_KEY);
|
|
15
|
-
req.currentAuth = payload;
|
|
16
|
-
}
|
|
17
|
-
catch (err) { }
|
|
18
|
-
next();
|
|
19
|
-
};
|
|
20
|
-
exports.currentAuth = currentAuth;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.verifyAdminApiKey = void 0;
|
|
4
|
-
const verifyAdminApiKey = (req, res, next) => {
|
|
5
|
-
let apiKey = req.header("x-api-key");
|
|
6
|
-
if (apiKey === process.env.ORIGINAL_ADMIN_API_KEY) {
|
|
7
|
-
req.validAdminApiKey = true;
|
|
8
|
-
}
|
|
9
|
-
next();
|
|
10
|
-
};
|
|
11
|
-
exports.verifyAdminApiKey = verifyAdminApiKey;
|
package/build/services/s3.d.ts
DELETED
package/build/services/s3.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.s3 = void 0;
|
|
4
|
-
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
5
|
-
class s3 {
|
|
6
|
-
constructor() {
|
|
7
|
-
this._client = new client_s3_1.S3Client({
|
|
8
|
-
endpoint: process.env.S3_ENDPOINT,
|
|
9
|
-
forcePathStyle: false,
|
|
10
|
-
region: process.env.S3_REGION,
|
|
11
|
-
credentials: {
|
|
12
|
-
accessKeyId: process.env.S3_ACCESS_KEY,
|
|
13
|
-
secretAccessKey: process.env.S3_SECRET_KEY, // Secret access key defined through an environment variable.
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
get client() {
|
|
18
|
-
return this._client;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.s3 = s3;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|