@riocrypto/common-server 1.0.1681 → 1.0.1683
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/axios-with-logging.d.ts +2 -0
- package/build/clients/axios-with-logging.js +35 -0
- package/build/clients/bitso-client.js +15 -15
- package/build/clients/bridge-client.js +16 -16
- package/build/clients/circle-client.js +6 -6
- package/build/clients/cluster-client.js +23 -15
- package/build/clients/coincover-client.js +2 -2
- package/build/clients/cosigner-client.js +2 -2
- package/build/clients/currency-api-client.js +3 -3
- package/build/clients/fireblocks-client.js +0 -1
- package/build/clients/slack-client.js +2 -2
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
const axios_1 = __importDefault(require("axios"));
|
|
7
|
+
const logger_1 = __importDefault(require("../services/logger"));
|
|
8
|
+
const axiosWithLogging = axios_1.default.create();
|
|
9
|
+
// Request Interceptor
|
|
10
|
+
axiosWithLogging.interceptors.request.use((config) => {
|
|
11
|
+
// Combine and log the full request configuration
|
|
12
|
+
const logMessage = `Request: method=${config.method}, url=${config.url}, headers=${JSON.stringify(config.headers)}, data=${JSON.stringify(config.data)}`;
|
|
13
|
+
logger_1.default.getLogger().info(logMessage);
|
|
14
|
+
return config;
|
|
15
|
+
}, (error) => {
|
|
16
|
+
// Log the request error with combined details
|
|
17
|
+
logger_1.default.getLogger().info(`Request Error: ${error}`);
|
|
18
|
+
return Promise.reject(error);
|
|
19
|
+
});
|
|
20
|
+
// Response Interceptor
|
|
21
|
+
axiosWithLogging.interceptors.response.use((response) => {
|
|
22
|
+
// Combine and log the full response details
|
|
23
|
+
const logMessage = `Response: url=${response.config.url}, status=${response.status}, data=${JSON.stringify(response.data)}`;
|
|
24
|
+
logger_1.default.getLogger().info(logMessage);
|
|
25
|
+
return response;
|
|
26
|
+
}, (error) => {
|
|
27
|
+
// Combine and log the response error details
|
|
28
|
+
let logMessage = `Response Error: url=${error.config ? error.config.url : "unknown"}, message=${error.message}`;
|
|
29
|
+
if (error.response) {
|
|
30
|
+
logMessage += `, status=${error.response.status}, data=${JSON.stringify(error.response.data)}`;
|
|
31
|
+
}
|
|
32
|
+
logger_1.default.getLogger().info(logMessage);
|
|
33
|
+
return Promise.reject(error);
|
|
34
|
+
});
|
|
35
|
+
exports.default = axiosWithLogging;
|
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.buildBitsoClient = void 0;
|
|
16
16
|
const secret_manager_client_1 = require("./secret-manager-client");
|
|
17
|
-
const
|
|
17
|
+
const axios_with_logging_1 = __importDefault(require("./axios-with-logging"));
|
|
18
18
|
const common_1 = require("@riocrypto/common");
|
|
19
19
|
const crypto_js_1 = __importDefault(require("crypto-js"));
|
|
20
20
|
class BitsoClient {
|
|
@@ -40,7 +40,7 @@ class BitsoClient {
|
|
|
40
40
|
},
|
|
41
41
|
};
|
|
42
42
|
const signedRequestConfig = this.signRequest(requestConfig);
|
|
43
|
-
const { data } = yield (0,
|
|
43
|
+
const { data } = yield (0, axios_with_logging_1.default)(signedRequestConfig);
|
|
44
44
|
return data.payload.clabe;
|
|
45
45
|
});
|
|
46
46
|
}
|
|
@@ -73,7 +73,7 @@ class BitsoClient {
|
|
|
73
73
|
},
|
|
74
74
|
};
|
|
75
75
|
const signedRequestConfig = this.signRequest(requestConfig);
|
|
76
|
-
const { data } = yield (0,
|
|
76
|
+
const { data } = yield (0, axios_with_logging_1.default)(signedRequestConfig);
|
|
77
77
|
if (!data.success) {
|
|
78
78
|
throw new Error("Error creating Bitso receiving account");
|
|
79
79
|
}
|
|
@@ -90,7 +90,7 @@ class BitsoClient {
|
|
|
90
90
|
url: `${this.baseUrl}/api/v3/consumer-contacts/${bitsoReceivingAccountId}`,
|
|
91
91
|
};
|
|
92
92
|
const signedRequestConfig = this.signRequest(requestConfig);
|
|
93
|
-
const { data } = yield (0,
|
|
93
|
+
const { data } = yield (0, axios_with_logging_1.default)(signedRequestConfig);
|
|
94
94
|
if (!data.success) {
|
|
95
95
|
throw new Error("Error deleting Bitso receiving account");
|
|
96
96
|
}
|
|
@@ -120,7 +120,7 @@ class BitsoClient {
|
|
|
120
120
|
},
|
|
121
121
|
};
|
|
122
122
|
const signedRequestConfig = this.signRequest(requestConfig);
|
|
123
|
-
const { data } = yield (0,
|
|
123
|
+
const { data } = yield (0, axios_with_logging_1.default)(signedRequestConfig);
|
|
124
124
|
if (!data.success) {
|
|
125
125
|
throw new Error("Error creating Bitso withdraw");
|
|
126
126
|
}
|
|
@@ -137,7 +137,7 @@ class BitsoClient {
|
|
|
137
137
|
},
|
|
138
138
|
};
|
|
139
139
|
const signedRequestConfig = this.signRequest(requestConfig);
|
|
140
|
-
const { data } = yield (0,
|
|
140
|
+
const { data } = yield (0, axios_with_logging_1.default)(signedRequestConfig);
|
|
141
141
|
if (!data.success || !data.payload.length) {
|
|
142
142
|
throw new Error("Error getting Bitso order");
|
|
143
143
|
}
|
|
@@ -166,7 +166,7 @@ class BitsoClient {
|
|
|
166
166
|
},
|
|
167
167
|
};
|
|
168
168
|
const signedRequestConfig = this.signRequest(requestConfig);
|
|
169
|
-
const { data } = yield (0,
|
|
169
|
+
const { data } = yield (0, axios_with_logging_1.default)(signedRequestConfig);
|
|
170
170
|
if (!data.success) {
|
|
171
171
|
throw new Error("Error creating Bitso limit order");
|
|
172
172
|
}
|
|
@@ -183,7 +183,7 @@ class BitsoClient {
|
|
|
183
183
|
},
|
|
184
184
|
};
|
|
185
185
|
const signedRequestConfig = this.signRequest(requestConfig);
|
|
186
|
-
const { data } = yield (0,
|
|
186
|
+
const { data } = yield (0, axios_with_logging_1.default)(signedRequestConfig);
|
|
187
187
|
if (!data.success || !data.payload.length) {
|
|
188
188
|
throw new Error("Error getting Bitso order");
|
|
189
189
|
}
|
|
@@ -200,7 +200,7 @@ class BitsoClient {
|
|
|
200
200
|
},
|
|
201
201
|
};
|
|
202
202
|
const signedRequestConfig = this.signRequest(requestConfig);
|
|
203
|
-
const { data } = yield (0,
|
|
203
|
+
const { data } = yield (0, axios_with_logging_1.default)(signedRequestConfig);
|
|
204
204
|
if (!data.success) {
|
|
205
205
|
throw new Error("Error getting Bitso order");
|
|
206
206
|
}
|
|
@@ -217,7 +217,7 @@ class BitsoClient {
|
|
|
217
217
|
},
|
|
218
218
|
};
|
|
219
219
|
const signedRequestConfig = this.signRequest(requestConfig);
|
|
220
|
-
const { data } = yield (0,
|
|
220
|
+
const { data } = yield (0, axios_with_logging_1.default)(signedRequestConfig);
|
|
221
221
|
if (!data.success) {
|
|
222
222
|
throw new Error("Error getting Bitso order trades");
|
|
223
223
|
}
|
|
@@ -234,7 +234,7 @@ class BitsoClient {
|
|
|
234
234
|
},
|
|
235
235
|
};
|
|
236
236
|
const signedRequestConfig = this.signRequest(requestConfig);
|
|
237
|
-
const { data } = yield (0,
|
|
237
|
+
const { data } = yield (0, axios_with_logging_1.default)(signedRequestConfig);
|
|
238
238
|
if (!data.success) {
|
|
239
239
|
throw new Error("Error getting Bitso order book trades");
|
|
240
240
|
}
|
|
@@ -254,7 +254,7 @@ class BitsoClient {
|
|
|
254
254
|
},
|
|
255
255
|
};
|
|
256
256
|
const signedRequestConfig = this.signRequest(requestConfig);
|
|
257
|
-
const { data } = yield (0,
|
|
257
|
+
const { data } = yield (0, axios_with_logging_1.default)(signedRequestConfig);
|
|
258
258
|
if (!data.success) {
|
|
259
259
|
throw new Error("Error deleting Bitso order");
|
|
260
260
|
}
|
|
@@ -270,7 +270,7 @@ class BitsoClient {
|
|
|
270
270
|
},
|
|
271
271
|
};
|
|
272
272
|
const signedRequestConfig = this.signRequest(requestConfig);
|
|
273
|
-
const { data } = yield (0,
|
|
273
|
+
const { data } = yield (0, axios_with_logging_1.default)(signedRequestConfig);
|
|
274
274
|
if (!data.success) {
|
|
275
275
|
throw new Error("Error getting Bitso order book");
|
|
276
276
|
}
|
|
@@ -287,7 +287,7 @@ class BitsoClient {
|
|
|
287
287
|
},
|
|
288
288
|
};
|
|
289
289
|
const signedRequestConfig = this.signRequest(requestConfig);
|
|
290
|
-
const res = yield (0,
|
|
290
|
+
const res = yield (0, axios_with_logging_1.default)(signedRequestConfig);
|
|
291
291
|
const data = res.data;
|
|
292
292
|
if (!data.success) {
|
|
293
293
|
throw new Error("Error getting Bitso fees");
|
|
@@ -310,7 +310,7 @@ class BitsoClient {
|
|
|
310
310
|
},
|
|
311
311
|
};
|
|
312
312
|
const signedRequestConfig = this.signRequest(requestConfig);
|
|
313
|
-
const res = yield (0,
|
|
313
|
+
const res = yield (0, axios_with_logging_1.default)(signedRequestConfig);
|
|
314
314
|
const data = res.data;
|
|
315
315
|
if (!data.success) {
|
|
316
316
|
throw new Error("Error getting Bitso fees");
|
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.buildBridgeClient = void 0;
|
|
16
16
|
const secret_manager_client_1 = require("./secret-manager-client");
|
|
17
|
-
const
|
|
17
|
+
const axios_with_logging_1 = __importDefault(require("./axios-with-logging"));
|
|
18
18
|
const common_1 = require("@riocrypto/common");
|
|
19
19
|
const uuid_1 = require("uuid");
|
|
20
20
|
class BridgeClient {
|
|
@@ -32,7 +32,7 @@ class BridgeClient {
|
|
|
32
32
|
if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local].includes(process.env.RIO_ENV)) {
|
|
33
33
|
throw new Error("Bridge KYC links are disabled in sandbox mode.");
|
|
34
34
|
}
|
|
35
|
-
const { data } = yield
|
|
35
|
+
const { data } = yield axios_with_logging_1.default.post(`${this.baseUrl}/v0/kyc_links`, {
|
|
36
36
|
full_name: fullName,
|
|
37
37
|
email,
|
|
38
38
|
type: userType,
|
|
@@ -47,7 +47,7 @@ class BridgeClient {
|
|
|
47
47
|
}
|
|
48
48
|
getKYCLink(id) {
|
|
49
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
const { data } = yield
|
|
50
|
+
const { data } = yield axios_with_logging_1.default.get(`${this.baseUrl}/v0/kyc_links/${id}`, {
|
|
51
51
|
headers: {
|
|
52
52
|
"Api-Key": this.apiKey,
|
|
53
53
|
},
|
|
@@ -60,7 +60,7 @@ class BridgeClient {
|
|
|
60
60
|
if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local].includes(process.env.RIO_ENV)) {
|
|
61
61
|
throw new Error("Bridge transfers are disabled in sandbox mode.");
|
|
62
62
|
}
|
|
63
|
-
const { data } = yield
|
|
63
|
+
const { data } = yield axios_with_logging_1.default.post(`${this.baseUrl}/v0/transfers`, {
|
|
64
64
|
amount: amountInUSD,
|
|
65
65
|
on_behalf_of: bridgeCustomerId,
|
|
66
66
|
developer_fee: developerFee,
|
|
@@ -77,7 +77,7 @@ class BridgeClient {
|
|
|
77
77
|
}
|
|
78
78
|
deleteTransfer(transferId) {
|
|
79
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
const { data } = yield
|
|
80
|
+
const { data } = yield axios_with_logging_1.default.delete(`${this.baseUrl}/v0/transfers/${transferId}`, {
|
|
81
81
|
headers: {
|
|
82
82
|
"Api-Key": this.apiKey,
|
|
83
83
|
},
|
|
@@ -87,7 +87,7 @@ class BridgeClient {
|
|
|
87
87
|
}
|
|
88
88
|
getTransfer(id) {
|
|
89
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
const { data } = yield
|
|
90
|
+
const { data } = yield axios_with_logging_1.default.get(`${this.baseUrl}/v0/transfers/${id}`, {
|
|
91
91
|
headers: {
|
|
92
92
|
"Api-Key": this.apiKey,
|
|
93
93
|
},
|
|
@@ -97,7 +97,7 @@ class BridgeClient {
|
|
|
97
97
|
}
|
|
98
98
|
getAllCustomerTransfers(customerId) {
|
|
99
99
|
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
-
const { data } = yield
|
|
100
|
+
const { data } = yield axios_with_logging_1.default.get(`${this.baseUrl}/v0/customers/${customerId}/transfers`, {
|
|
101
101
|
headers: {
|
|
102
102
|
"Api-Key": this.apiKey,
|
|
103
103
|
},
|
|
@@ -110,7 +110,7 @@ class BridgeClient {
|
|
|
110
110
|
if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local].includes(process.env.RIO_ENV)) {
|
|
111
111
|
throw new Error("Bridge liquidation addresses are disabled in sandbox mode.");
|
|
112
112
|
}
|
|
113
|
-
const { data } = yield
|
|
113
|
+
const { data } = yield axios_with_logging_1.default.post(`${this.baseUrl}/v0/customers/${bridgeCustomerId}/liquidation_addresses`, {
|
|
114
114
|
currency,
|
|
115
115
|
chain,
|
|
116
116
|
external_account_id: externalAccountId,
|
|
@@ -125,7 +125,7 @@ class BridgeClient {
|
|
|
125
125
|
}
|
|
126
126
|
getLiquidationAddresses(bridgeCustomerId, crypto) {
|
|
127
127
|
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
-
const { data } = yield
|
|
128
|
+
const { data } = yield axios_with_logging_1.default.get(`${this.baseUrl}/v0/customers/${bridgeCustomerId}/liquidation_addresses/`, {
|
|
129
129
|
headers: {
|
|
130
130
|
"Api-Key": this.apiKey,
|
|
131
131
|
},
|
|
@@ -137,7 +137,7 @@ class BridgeClient {
|
|
|
137
137
|
}
|
|
138
138
|
getLiquidationAddress(bridgeCustomerId, bridgeLiquidationAddressId) {
|
|
139
139
|
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
-
const { data } = yield
|
|
140
|
+
const { data } = yield axios_with_logging_1.default.get(`${this.baseUrl}/v0/customers/${bridgeCustomerId}/liquidation_addresses/${bridgeLiquidationAddressId}`, {
|
|
141
141
|
headers: {
|
|
142
142
|
"Api-Key": this.apiKey,
|
|
143
143
|
},
|
|
@@ -147,7 +147,7 @@ class BridgeClient {
|
|
|
147
147
|
}
|
|
148
148
|
getLiquidationAddressDrains(bridgeCustomerId, liquidationAddressId) {
|
|
149
149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
150
|
-
const response = yield
|
|
150
|
+
const response = yield axios_with_logging_1.default.get(`${this.baseUrl}/v0/customers/${bridgeCustomerId}/liquidation_addresses/${liquidationAddressId}/drains`, {
|
|
151
151
|
headers: {
|
|
152
152
|
"Api-Key": this.apiKey,
|
|
153
153
|
},
|
|
@@ -160,7 +160,7 @@ class BridgeClient {
|
|
|
160
160
|
if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local].includes(process.env.RIO_ENV)) {
|
|
161
161
|
throw new Error("Bridge plaid link tokens are disabled in sandbox mode.");
|
|
162
162
|
}
|
|
163
|
-
const { data } = yield
|
|
163
|
+
const { data } = yield axios_with_logging_1.default.post(`${this.baseUrl}/v0/customers/${bridgeCustomerId}/plaid_link_requests`, undefined, {
|
|
164
164
|
headers: {
|
|
165
165
|
"Api-Key": this.apiKey,
|
|
166
166
|
"Idempotency-Key": (0, uuid_1.v4)(),
|
|
@@ -171,7 +171,7 @@ class BridgeClient {
|
|
|
171
171
|
}
|
|
172
172
|
getExternalAccounts(customerId) {
|
|
173
173
|
return __awaiter(this, void 0, void 0, function* () {
|
|
174
|
-
const { data } = yield
|
|
174
|
+
const { data } = yield axios_with_logging_1.default.get(`${this.baseUrl}/v0/customers/${customerId}/external_accounts`, {
|
|
175
175
|
headers: {
|
|
176
176
|
"Api-Key": this.apiKey,
|
|
177
177
|
},
|
|
@@ -182,7 +182,7 @@ class BridgeClient {
|
|
|
182
182
|
getExternalAccount(bridgeCustomerId, externalAccountId) {
|
|
183
183
|
return __awaiter(this, void 0, void 0, function* () {
|
|
184
184
|
console.log("getting external account", `${this.baseUrl}/v0/customers/${bridgeCustomerId}/external_accounts/${externalAccountId}`);
|
|
185
|
-
const { data } = yield
|
|
185
|
+
const { data } = yield axios_with_logging_1.default.get(`${this.baseUrl}/v0/customers/${bridgeCustomerId}/external_accounts/${externalAccountId}`, {
|
|
186
186
|
headers: {
|
|
187
187
|
"Api-Key": this.apiKey,
|
|
188
188
|
},
|
|
@@ -195,7 +195,7 @@ class BridgeClient {
|
|
|
195
195
|
if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local].includes(process.env.RIO_ENV)) {
|
|
196
196
|
throw new Error("Bridge plaid exchange public token is disabled in sandbox mode.");
|
|
197
197
|
}
|
|
198
|
-
const { data } = yield
|
|
198
|
+
const { data } = yield axios_with_logging_1.default.post(`${this.baseUrl}/v0/plaid_exchange_public_token/${linkToken}`, {
|
|
199
199
|
public_token: publicToken,
|
|
200
200
|
}, {
|
|
201
201
|
headers: {
|
|
@@ -210,7 +210,7 @@ class BridgeClient {
|
|
|
210
210
|
if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local].includes(process.env.RIO_ENV)) {
|
|
211
211
|
throw new Error("Bridge external accounts are disabled in sandbox mode.");
|
|
212
212
|
}
|
|
213
|
-
const { data } = yield
|
|
213
|
+
const { data } = yield axios_with_logging_1.default.post(`${this.baseUrl}/v0/customers/${bridgeCustomerId}/external_accounts`, {
|
|
214
214
|
type: "wire",
|
|
215
215
|
bank_name: bankName,
|
|
216
216
|
account_number: accountNumber,
|
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.buildCircleClient = void 0;
|
|
16
16
|
const secret_manager_client_1 = require("./secret-manager-client");
|
|
17
|
-
const
|
|
17
|
+
const axios_with_logging_1 = __importDefault(require("./axios-with-logging"));
|
|
18
18
|
const common_1 = require("@riocrypto/common");
|
|
19
19
|
const uuid_1 = require("uuid");
|
|
20
20
|
class CircleClient {
|
|
@@ -29,7 +29,7 @@ class CircleClient {
|
|
|
29
29
|
var _a;
|
|
30
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
31
|
const uuid = (0, uuid_1.v1)();
|
|
32
|
-
const response = yield
|
|
32
|
+
const response = yield axios_with_logging_1.default.post(`${this.baseUrl}/v1/addressBook/recipients`, {
|
|
33
33
|
idempotencyKey: uuid,
|
|
34
34
|
chain,
|
|
35
35
|
address,
|
|
@@ -47,7 +47,7 @@ class CircleClient {
|
|
|
47
47
|
getAddressBookRecipient(id) {
|
|
48
48
|
var _a;
|
|
49
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
const response = yield
|
|
50
|
+
const response = yield axios_with_logging_1.default.get(`${this.baseUrl}/v1/addressBook/recipients/${id}`, {
|
|
51
51
|
headers: {
|
|
52
52
|
Authorization: `Bearer ${this.apiKey}`,
|
|
53
53
|
},
|
|
@@ -59,7 +59,7 @@ class CircleClient {
|
|
|
59
59
|
var _a;
|
|
60
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
61
|
const uuid = (0, uuid_1.v1)();
|
|
62
|
-
const response = yield
|
|
62
|
+
const response = yield axios_with_logging_1.default.post(`${this.baseUrl}/v1/payouts`, {
|
|
63
63
|
idempotencyKey: uuid,
|
|
64
64
|
source: {
|
|
65
65
|
type: "wallet",
|
|
@@ -103,7 +103,7 @@ class CircleClient {
|
|
|
103
103
|
getPayout(id) {
|
|
104
104
|
var _a;
|
|
105
105
|
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
-
const response = yield
|
|
106
|
+
const response = yield axios_with_logging_1.default.get(`${this.baseUrl}/v1/payouts/${id}`, {
|
|
107
107
|
headers: {
|
|
108
108
|
Authorization: `Bearer ${this.apiKey}`,
|
|
109
109
|
},
|
|
@@ -113,7 +113,7 @@ class CircleClient {
|
|
|
113
113
|
}
|
|
114
114
|
getUSDCBalance(walletId) {
|
|
115
115
|
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
-
const response = yield
|
|
116
|
+
const response = yield axios_with_logging_1.default.get(`${this.baseUrl}/v1/wallets/${walletId}`, {
|
|
117
117
|
headers: {
|
|
118
118
|
Authorization: `Bearer ${this.apiKey}`,
|
|
119
119
|
},
|
|
@@ -14,26 +14,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.buildClusterClient = void 0;
|
|
16
16
|
const common_1 = require("@riocrypto/common");
|
|
17
|
-
const
|
|
17
|
+
const axios_with_logging_1 = __importDefault(require("./axios-with-logging"));
|
|
18
18
|
const secret_manager_client_1 = require("./secret-manager-client");
|
|
19
19
|
class ClusterClient {
|
|
20
20
|
constructor(baseUrl, clusterApiKey) {
|
|
21
21
|
this.baseUrl = baseUrl;
|
|
22
22
|
this.clusterApiKey = clusterApiKey;
|
|
23
|
-
this.axios =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
this.axios = axios_with_logging_1.default;
|
|
24
|
+
this.axios.defaults.baseURL = baseUrl;
|
|
25
|
+
// Set the Host header based on environment
|
|
26
|
+
const environment = process.env.RIO_ENV;
|
|
27
|
+
let hostHeader;
|
|
28
|
+
switch (environment) {
|
|
29
|
+
case common_1.RioEnv.Local:
|
|
30
|
+
hostHeader = "";
|
|
31
|
+
break;
|
|
32
|
+
case common_1.RioEnv.Development:
|
|
33
|
+
hostHeader = "dev.riotransfer.co";
|
|
34
|
+
break;
|
|
35
|
+
case common_1.RioEnv.Production:
|
|
36
|
+
hostHeader = "www.riotransfer.co";
|
|
37
|
+
break;
|
|
38
|
+
case common_1.RioEnv.Sandbox:
|
|
39
|
+
hostHeader = "sandbox.riotransfer.co";
|
|
40
|
+
break;
|
|
41
|
+
default:
|
|
42
|
+
hostHeader = "sandbox.riotransfer.co";
|
|
43
|
+
}
|
|
44
|
+
this.axios.defaults.headers.common["Host"] = hostHeader;
|
|
37
45
|
}
|
|
38
46
|
getNewQuote(orderId, quote, newAmountFiat, newAmountCrypto) {
|
|
39
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.buildCoincoverClient = void 0;
|
|
16
16
|
const secret_manager_client_1 = require("./secret-manager-client");
|
|
17
|
-
const
|
|
17
|
+
const axios_with_logging_1 = __importDefault(require("./axios-with-logging"));
|
|
18
18
|
const common_1 = require("@riocrypto/common");
|
|
19
19
|
class CoincoverClient {
|
|
20
20
|
constructor(apiKey) {
|
|
@@ -41,7 +41,7 @@ class CoincoverClient {
|
|
|
41
41
|
}
|
|
42
42
|
checkTransaction(transactionId, userId, crypto, originVaultOrExchangeId, destinationAddress, amount) {
|
|
43
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
const { data } = yield
|
|
44
|
+
const { data } = yield axios_with_logging_1.default.post(`${this.baseUrl}/transaction`, {
|
|
45
45
|
transactionCustomerId: transactionId,
|
|
46
46
|
coin: this.coingeckoMappings[crypto],
|
|
47
47
|
walletId: `${originVaultOrExchangeId}-${crypto}`,
|
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.buildCosignerClient = void 0;
|
|
16
16
|
const secret_manager_client_1 = require("./secret-manager-client");
|
|
17
|
-
const
|
|
17
|
+
const axios_with_logging_1 = __importDefault(require("./axios-with-logging"));
|
|
18
18
|
const crypto_1 = __importDefault(require("crypto"));
|
|
19
19
|
class CosignerClient {
|
|
20
20
|
constructor(apiKey, webhookSecret) {
|
|
@@ -23,7 +23,7 @@ class CosignerClient {
|
|
|
23
23
|
}
|
|
24
24
|
sendRequest(title, description, minApprovers, notificationUrl, approverGroupId, metadata) {
|
|
25
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
yield
|
|
26
|
+
yield axios_with_logging_1.default.post("http://www.cosigner.xyz/api/requests", {
|
|
27
27
|
title,
|
|
28
28
|
description,
|
|
29
29
|
metadata,
|
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.buildCurrencyAPIClient = void 0;
|
|
16
16
|
const common_1 = require("@riocrypto/common");
|
|
17
|
-
const
|
|
17
|
+
const axios_with_logging_1 = __importDefault(require("./axios-with-logging"));
|
|
18
18
|
const secret_manager_client_1 = require("./secret-manager-client");
|
|
19
19
|
const node_cache_1 = __importDefault(require("node-cache"));
|
|
20
20
|
const cache = new node_cache_1.default({ stdTTL: 10 });
|
|
@@ -31,7 +31,7 @@ class CurrencyAPIClient {
|
|
|
31
31
|
exchangeRate = cachedResponse.data[to].value;
|
|
32
32
|
}
|
|
33
33
|
else {
|
|
34
|
-
const currencyAPIResponse = yield
|
|
34
|
+
const currencyAPIResponse = yield axios_with_logging_1.default.get(`https://api.currencyapi.com/v3/latest?apikey=${this.apiKey}&base_currency=${from}¤cies=${to}`);
|
|
35
35
|
exchangeRate = currencyAPIResponse.data.data[to].value;
|
|
36
36
|
cache.set(`v3/latest?apikey=${this.apiKey}&base_currency=${from}¤cies=${to}`, currencyAPIResponse.data);
|
|
37
37
|
}
|
|
@@ -59,7 +59,7 @@ class CurrencyAPIClient {
|
|
|
59
59
|
exchangeRates = cachedResponse.data;
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
62
|
-
const currencyAPIResponse = yield
|
|
62
|
+
const currencyAPIResponse = yield axios_with_logging_1.default.get(`https://api.currencyapi.com/v3/range?apikey=${this.apiKey}&datetime_start=${start}&datetime_end=${end}&accuracy=minute¤cies=${to}&base_currency=${from}`);
|
|
63
63
|
exchangeRates = currencyAPIResponse.data.data;
|
|
64
64
|
cache.set(`v3/range?apikey=${this.apiKey}&datetime_start=${start}&datetime_end=${end}&accuracy=minute¤cies=${to}&base_currency=${from}`, currencyAPIResponse.data);
|
|
65
65
|
}
|
|
@@ -13,13 +13,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.slackClient = void 0;
|
|
16
|
-
const
|
|
16
|
+
const axios_with_logging_1 = __importDefault(require("./axios-with-logging"));
|
|
17
17
|
class SlackClient {
|
|
18
18
|
constructor() { }
|
|
19
19
|
sendMessageWithWebhook(message, webhookUrl) {
|
|
20
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
21
|
try {
|
|
22
|
-
yield
|
|
22
|
+
yield axios_with_logging_1.default.post(webhookUrl, {
|
|
23
23
|
text: message,
|
|
24
24
|
});
|
|
25
25
|
}
|
package/build/index.d.ts
CHANGED
|
@@ -59,6 +59,7 @@ export * from "./models/bank-account-verification";
|
|
|
59
59
|
export * from "./models/coincover-transaction";
|
|
60
60
|
export * from "./models/coinbase-order";
|
|
61
61
|
export * from "./models/multipart-liquidity-order";
|
|
62
|
+
export * from "./clients/axios-with-logging";
|
|
62
63
|
export * from "./clients/slack-client";
|
|
63
64
|
export * from "./clients/fireblocks-client";
|
|
64
65
|
export * from "./clients/secret-manager-client";
|
package/build/index.js
CHANGED
|
@@ -75,6 +75,7 @@ __exportStar(require("./models/bank-account-verification"), exports);
|
|
|
75
75
|
__exportStar(require("./models/coincover-transaction"), exports);
|
|
76
76
|
__exportStar(require("./models/coinbase-order"), exports);
|
|
77
77
|
__exportStar(require("./models/multipart-liquidity-order"), exports);
|
|
78
|
+
__exportStar(require("./clients/axios-with-logging"), exports);
|
|
78
79
|
__exportStar(require("./clients/slack-client"), exports);
|
|
79
80
|
__exportStar(require("./clients/fireblocks-client"), exports);
|
|
80
81
|
__exportStar(require("./clients/secret-manager-client"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1683",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@google-cloud/secret-manager": "^5.3.0",
|
|
27
27
|
"@google-cloud/storage": "^6.9.5",
|
|
28
28
|
"@hyperdx/node-opentelemetry": "^0.4.2",
|
|
29
|
-
"@riocrypto/common": "^1.0.
|
|
29
|
+
"@riocrypto/common": "^1.0.1483",
|
|
30
30
|
"@types/express": "^4.17.13",
|
|
31
31
|
"axios": "^1.6.0",
|
|
32
32
|
"crypto-js": "^4.2.0",
|