@riocrypto/common-server 1.0.550 → 1.0.557
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/clients/bitstamp-client.js +5 -6
- package/build/clients/ccxt-client.js +5 -4
- package/build/clients/etherscan-client.js +2 -2
- package/build/clients/fireblocks-client.js +5 -6
- package/build/clients/fixer-client.js +7 -7
- package/build/clients/gueno-client.js +8 -8
- package/build/clients/kushki-client.js +2 -1
- package/build/clients/s3-client.js +8 -10
- package/build/clients/secret-manager-client.d.ts +11 -0
- package/build/clients/secret-manager-client.js +90 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/middlewares/authorize.js +4 -3
- package/build/middlewares/current-admin-auth.js +2 -2
- package/build/middlewares/current-auth.js +2 -2
- package/build/middlewares/get-partner.js +2 -2
- package/build/middlewares/verify-admin-api-key.js +2 -2
- package/build/services/apiKey.js +2 -2
- package/package.json +2 -2
|
@@ -36,10 +36,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.bitstampClient = void 0;
|
|
39
|
-
const common_1 = require("@riocrypto/common");
|
|
40
39
|
const axios_1 = __importDefault(require("axios"));
|
|
41
40
|
const crypto = __importStar(require("crypto"));
|
|
42
41
|
const uuid = __importStar(require("uuid"));
|
|
42
|
+
const secret_manager_client_1 = require("./secret-manager-client");
|
|
43
43
|
class BitstampClient {
|
|
44
44
|
constructor(apiKey, apiSecret) {
|
|
45
45
|
this.apiKey = apiKey;
|
|
@@ -81,16 +81,15 @@ class BitstampClient {
|
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
|
|
85
|
-
const BITSTAMP_API_KEY = yield
|
|
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
86
|
if (!BITSTAMP_API_KEY) {
|
|
87
87
|
throw new Error("Unable to get BITSTAMP_API_KEY");
|
|
88
88
|
}
|
|
89
|
-
const BITSTAMP_SECRET = yield
|
|
89
|
+
const BITSTAMP_SECRET = yield secret_manager_client_1.secretManagerClient.getSecretValue("BITSTAMP_SECRET");
|
|
90
90
|
if (!BITSTAMP_SECRET) {
|
|
91
91
|
throw new Error("Unable to get BITSTAMP_SECRET");
|
|
92
92
|
}
|
|
93
93
|
const bitstampClient = new BitstampClient(BITSTAMP_API_KEY, BITSTAMP_SECRET);
|
|
94
94
|
return bitstampClient;
|
|
95
|
-
});
|
|
96
|
-
exports.bitstampClient = createBitstampClient();
|
|
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,11 +124,11 @@ 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") {
|
|
126
|
-
const SECRET = yield
|
|
127
|
+
const SECRET = yield secret_manager_client_1.secretManagerClient.getSecretValue(`${exchangeId.toLocaleUpperCase()}_SECRET`);
|
|
127
128
|
if (!SECRET) {
|
|
128
129
|
throw new Error("Unable to get SECRET");
|
|
129
130
|
}
|
|
130
|
-
const API_KEY = yield
|
|
131
|
+
const API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue(`${exchangeId.toLocaleUpperCase()}_API_KEY`);
|
|
131
132
|
if (!API_KEY) {
|
|
132
133
|
throw new Error("Unable to get API_KEY");
|
|
133
134
|
}
|
|
@@ -154,11 +155,11 @@ class CCXTClient {
|
|
|
154
155
|
}
|
|
155
156
|
getExchange(ccxtLiquidityProvider) {
|
|
156
157
|
return __awaiter(this, void 0, void 0, function* () {
|
|
157
|
-
const SECRET = yield
|
|
158
|
+
const SECRET = yield secret_manager_client_1.secretManagerClient.getSecretValue(`${ccxtLiquidityProvider.toLocaleUpperCase()}_SECRET`);
|
|
158
159
|
if (!SECRET) {
|
|
159
160
|
throw new Error("Unable to get SECRET");
|
|
160
161
|
}
|
|
161
|
-
const API_KEY = yield
|
|
162
|
+
const API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue(`${ccxtLiquidityProvider.toLocaleUpperCase()}_API_KEY`);
|
|
162
163
|
if (!API_KEY) {
|
|
163
164
|
throw new Error("Unable to get API_KEY");
|
|
164
165
|
}
|
|
@@ -10,14 +10,14 @@ 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
|
|
13
|
+
const secret_manager_client_1 = require("./secret-manager-client");
|
|
14
14
|
class EtherscanClient {
|
|
15
15
|
constructor(axios) {
|
|
16
16
|
this.axios = axios;
|
|
17
17
|
}
|
|
18
18
|
getTransactions(address) {
|
|
19
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const ETHERSCAN_API_KEY = yield
|
|
20
|
+
const ETHERSCAN_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("ETHERSCAN_API_KEY");
|
|
21
21
|
if (!ETHERSCAN_API_KEY) {
|
|
22
22
|
throw new Error("Unable to get ETHERSCAN_API_KEY");
|
|
23
23
|
}
|
|
@@ -11,7 +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
|
|
14
|
+
const secret_manager_client_1 = require("./secret-manager-client");
|
|
15
15
|
class FireblocksClient {
|
|
16
16
|
constructor(privateKey, apiKey) {
|
|
17
17
|
this.fireblocks = new fireblocks_sdk_1.FireblocksSDK(privateKey, apiKey, "https://api.fireblocks.io");
|
|
@@ -143,16 +143,15 @@ class FireblocksClient {
|
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
|
|
147
|
-
const FIREBLOCKS_PRIVATE_KEY = yield
|
|
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
148
|
if (!FIREBLOCKS_PRIVATE_KEY) {
|
|
149
149
|
throw new Error("Unable to get FIREBLOCKS_PRIVATE_KEY");
|
|
150
150
|
}
|
|
151
|
-
const FIREBLOCKS_API_KEY = yield
|
|
151
|
+
const FIREBLOCKS_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("FIREBLOCKS_API_KEY");
|
|
152
152
|
if (!FIREBLOCKS_API_KEY) {
|
|
153
153
|
throw new Error("Unable to get FIREBLOCKS_API_KEY");
|
|
154
154
|
}
|
|
155
155
|
const fireblocksClient = new FireblocksClient(FIREBLOCKS_PRIVATE_KEY, FIREBLOCKS_API_KEY);
|
|
156
156
|
return fireblocksClient;
|
|
157
|
-
});
|
|
158
|
-
exports.fireblocksClient = createFireblocksClient();
|
|
157
|
+
}))();
|
|
@@ -13,8 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.fixerClient = void 0;
|
|
16
|
-
const common_1 = require("@riocrypto/common");
|
|
17
16
|
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
const secret_manager_client_1 = require("./secret-manager-client");
|
|
18
18
|
class FixerClient {
|
|
19
19
|
constructor(apiKey) {
|
|
20
20
|
this.apiKey = apiKey;
|
|
@@ -32,12 +32,12 @@ class FixerClient {
|
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
|
|
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");
|
|
37
38
|
if (!FIXER_API_KEY) {
|
|
38
39
|
throw new Error("Unable to get FIXER_API_KEY");
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
-
return
|
|
42
|
-
});
|
|
43
|
-
exports.fixerClient = createFixerClient();
|
|
41
|
+
// Create FixerClient instance and return
|
|
42
|
+
return new FixerClient(FIXER_API_KEY);
|
|
43
|
+
}))();
|
|
@@ -13,7 +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
|
|
16
|
+
const secret_manager_client_1 = require("./secret-manager-client");
|
|
17
17
|
const axios_1 = __importDefault(require("axios"));
|
|
18
18
|
class GuenoClient {
|
|
19
19
|
constructor(email, password, env) {
|
|
@@ -42,16 +42,16 @@ class GuenoClient {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
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");
|
|
47
48
|
if (!GUENO_EMAIL) {
|
|
48
49
|
throw new Error("Unable to get GUENO_EMAIL");
|
|
49
50
|
}
|
|
50
|
-
const GUENO_PASSWORD = yield
|
|
51
|
+
const GUENO_PASSWORD = yield secret_manager_client_1.secretManagerClient.getSecretValue("GUENO_PASSWORD");
|
|
51
52
|
if (!GUENO_PASSWORD) {
|
|
52
53
|
throw new Error("Unable to get GUENO_PASSWORD");
|
|
53
54
|
}
|
|
54
|
-
|
|
55
|
-
return
|
|
56
|
-
});
|
|
57
|
-
exports.guenoClient = createGuenoClient();
|
|
55
|
+
// Create GuenoClient instance and return
|
|
56
|
+
return new GuenoClient(GUENO_EMAIL, GUENO_PASSWORD, process.env.GUENO_ENV);
|
|
57
|
+
}))();
|
|
@@ -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;
|
|
@@ -148,7 +149,7 @@ class KushkiClient {
|
|
|
148
149
|
}
|
|
149
150
|
}
|
|
150
151
|
const createKushkiClient = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
151
|
-
const KUSHKI_PRIVATE_MERCHANT_ID = yield
|
|
152
|
+
const KUSHKI_PRIVATE_MERCHANT_ID = yield secret_manager_client_1.secretManagerClient.getSecretValue("KUSHKI_PRIVATE_MERCHANT_ID");
|
|
152
153
|
if (!KUSHKI_PRIVATE_MERCHANT_ID) {
|
|
153
154
|
throw new Error("Unable to get KUSHKI_PRIVATE_MERCHANT_ID");
|
|
154
155
|
}
|
|
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.s3Client = exports.s3 = void 0;
|
|
13
13
|
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
14
|
-
const
|
|
14
|
+
const secret_manager_client_1 = require("./secret-manager-client");
|
|
15
15
|
class s3 {
|
|
16
16
|
constructor(endpoint, region, accessKey, secretKey) {
|
|
17
17
|
this._client = new client_s3_1.S3Client({
|
|
@@ -29,24 +29,22 @@ class s3 {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
exports.s3 = s3;
|
|
32
|
-
|
|
33
|
-
const S3_ENDPOINT = yield
|
|
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
34
|
if (!S3_ENDPOINT) {
|
|
35
35
|
throw new Error("Unable to get S3_ENDPOINT");
|
|
36
36
|
}
|
|
37
|
-
const S3_ACCESS_KEY = yield
|
|
37
|
+
const S3_ACCESS_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("S3_ACCESS_KEY");
|
|
38
38
|
if (!S3_ACCESS_KEY) {
|
|
39
39
|
throw new Error("Unable to get S3_ACCESS_KEY");
|
|
40
40
|
}
|
|
41
|
-
const S3_SECRET_KEY = yield
|
|
41
|
+
const S3_SECRET_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("S3_SECRET_KEY");
|
|
42
42
|
if (!S3_SECRET_KEY) {
|
|
43
43
|
throw new Error("Unable to get S3_SECRET_KEY");
|
|
44
44
|
}
|
|
45
|
-
const S3_REGION = yield
|
|
45
|
+
const S3_REGION = yield secret_manager_client_1.secretManagerClient.getSecretValue("S3_REGION");
|
|
46
46
|
if (!S3_REGION) {
|
|
47
47
|
throw new Error("Unable to get S3_REGION");
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
});
|
|
52
|
-
exports.s3Client = createS3Client();
|
|
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 "@riocrypto/common";
|
|
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 common_1 = require("@riocrypto/common");
|
|
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 === common_1.RioEnv.Development) {
|
|
61
|
+
file = "dev-secrets";
|
|
62
|
+
}
|
|
63
|
+
else if (this.env === common_1.RioEnv.Sandbox) {
|
|
64
|
+
file = "sandbox-secrets";
|
|
65
|
+
}
|
|
66
|
+
else if (this.env === common_1.RioEnv.Staging) {
|
|
67
|
+
file = "staging-secrets";
|
|
68
|
+
}
|
|
69
|
+
else if (this.env === common_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);
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -54,4 +54,5 @@ __exportStar(require("./clients/kapstar-client"), exports);
|
|
|
54
54
|
__exportStar(require("./clients/etherscan-client"), exports);
|
|
55
55
|
__exportStar(require("./clients/rio-client"), exports);
|
|
56
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,13 @@ 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
|
-
const ADMIN_API_KEY = yield
|
|
29
|
+
const ADMIN_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("ADMIN_API_KEY");
|
|
29
30
|
if (!ADMIN_API_KEY) {
|
|
30
31
|
throw new Error("Unable to get ADMIN_API_KEY");
|
|
31
32
|
}
|
|
@@ -67,7 +68,7 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
67
68
|
}
|
|
68
69
|
else if ((_a = req.cookies) === null || _a === void 0 ? void 0 : _a.accessToken) {
|
|
69
70
|
try {
|
|
70
|
-
const ACCESS_TOKEN_SECRET = yield
|
|
71
|
+
const ACCESS_TOKEN_SECRET = yield secret_manager_client_1.secretManagerClient.getSecretValue("ACCESS_TOKEN_SECRET");
|
|
71
72
|
if (!ACCESS_TOKEN_SECRET) {
|
|
72
73
|
throw new Error("Unable to get ACCESS_TOKEN_SECRET");
|
|
73
74
|
}
|
|
@@ -88,7 +89,7 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
88
89
|
if (authorizationTypes.includes(common_1.AuthorizationType.Admin)) {
|
|
89
90
|
if ((_f = req.cookies) === null || _f === void 0 ? void 0 : _f.adminAccessToken) {
|
|
90
91
|
try {
|
|
91
|
-
const ADMIN_ACCESS_TOKEN_SECRET = yield
|
|
92
|
+
const ADMIN_ACCESS_TOKEN_SECRET = yield secret_manager_client_1.secretManagerClient.getSecretValue("ADMIN_ACCESS_TOKEN_SECRET");
|
|
92
93
|
if (!ADMIN_ACCESS_TOKEN_SECRET) {
|
|
93
94
|
throw new Error("Unable to get ADMIN_ACCESS_TOKEN_SECRET");
|
|
94
95
|
}
|
|
@@ -13,15 +13,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.currentAdminAuth = void 0;
|
|
16
|
-
const common_1 = require("@riocrypto/common");
|
|
17
16
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
17
|
+
const secret_manager_client_1 = require("../clients/secret-manager-client");
|
|
18
18
|
const currentAdminAuth = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
19
|
var _a;
|
|
20
20
|
if (!((_a = req.cookies) === null || _a === void 0 ? void 0 : _a.adminAccesToken)) {
|
|
21
21
|
return next();
|
|
22
22
|
}
|
|
23
23
|
try {
|
|
24
|
-
const ADMIN_ACCESS_TOKEN_SECRET = yield
|
|
24
|
+
const ADMIN_ACCESS_TOKEN_SECRET = yield secret_manager_client_1.secretManagerClient.getSecretValue("ADMIN_ACCESS_TOKEN_SECRET");
|
|
25
25
|
if (!ADMIN_ACCESS_TOKEN_SECRET) {
|
|
26
26
|
throw new Error("ADMIN_ACCESS_TOKEN_SECRET");
|
|
27
27
|
}
|
|
@@ -13,15 +13,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.currentAuth = void 0;
|
|
16
|
-
const common_1 = require("@riocrypto/common");
|
|
17
16
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
17
|
+
const secret_manager_client_1 = require("../clients/secret-manager-client");
|
|
18
18
|
const currentAuth = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
19
|
var _a;
|
|
20
20
|
if (!((_a = req.cookies) === null || _a === void 0 ? void 0 : _a.accessToken)) {
|
|
21
21
|
return next();
|
|
22
22
|
}
|
|
23
23
|
try {
|
|
24
|
-
const ACCESS_TOKEN_SECRET = yield
|
|
24
|
+
const ACCESS_TOKEN_SECRET = yield secret_manager_client_1.secretManagerClient.getSecretValue("ACCESS_TOKEN_SECRET");
|
|
25
25
|
if (!ACCESS_TOKEN_SECRET) {
|
|
26
26
|
throw new Error("Unable to get ACCESS_TOKEN_SECRET");
|
|
27
27
|
}
|
|
@@ -16,11 +16,11 @@ 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
|
|
19
|
+
const secret_manager_client_1 = require("../clients/secret-manager-client");
|
|
20
20
|
const getPartner = (req, res, next, mongoose) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
21
|
try {
|
|
22
22
|
if (!req.headers["x-api-key"]) {
|
|
23
|
-
const PARTNER_ACCESS_TOKEN_SECRET = yield
|
|
23
|
+
const PARTNER_ACCESS_TOKEN_SECRET = yield secret_manager_client_1.secretManagerClient.getSecretValue("PARTNER_ACCESS_TOKEN_SECRET");
|
|
24
24
|
if (!PARTNER_ACCESS_TOKEN_SECRET) {
|
|
25
25
|
throw new Error("Unable to get PARTNER_ACCESS_TOKEN_SECRET");
|
|
26
26
|
}
|
|
@@ -10,10 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.verifyAdminApiKey = void 0;
|
|
13
|
-
const
|
|
13
|
+
const secret_manager_client_1 = require("../clients/secret-manager-client");
|
|
14
14
|
const verifyAdminApiKey = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
15
|
let apiKey = req.header("x-api-key");
|
|
16
|
-
const ADMIN_API_KEY = yield
|
|
16
|
+
const ADMIN_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("ADMIN_API_KEY");
|
|
17
17
|
if (!ADMIN_API_KEY) {
|
|
18
18
|
throw new Error("Unable to get ADMIN_API_KEY");
|
|
19
19
|
}
|
package/build/services/apiKey.js
CHANGED
|
@@ -10,12 +10,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ApiKey = void 0;
|
|
13
|
-
const common_1 = require("@riocrypto/common");
|
|
14
13
|
const crypto_1 = require("crypto");
|
|
14
|
+
const secret_manager_client_1 = require("../clients/secret-manager-client");
|
|
15
15
|
class ApiKey {
|
|
16
16
|
static toHash(apiKey) {
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
const API_KEY_SALT = yield
|
|
18
|
+
const API_KEY_SALT = yield secret_manager_client_1.secretManagerClient.getSecretValue("API_KEY_SALT");
|
|
19
19
|
if (!API_KEY_SALT) {
|
|
20
20
|
throw new Error("Unable to get API_KEY_SALT");
|
|
21
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.557",
|
|
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",
|