@riocrypto/common-server 1.0.1555 → 1.0.1559
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/aiprise-client.js +4 -0
- package/build/clients/bitso-client.js +5 -5
- package/build/clients/bridge-client.js +6 -6
- package/build/clients/fireblocks-client.js +9 -9
- package/build/clients/invopop-client.js +1 -1
- package/build/middlewares/authorize.d.ts +1 -0
- package/build/middlewares/authorize.js +15 -0
- package/package.json +2 -2
|
@@ -22,6 +22,8 @@ class AiPriseClient {
|
|
|
22
22
|
this.decafApiKey = decafApiKey;
|
|
23
23
|
this.getCallbackUrl = (rioEnv) => {
|
|
24
24
|
switch (rioEnv) {
|
|
25
|
+
case common_1.RioEnv.Local:
|
|
26
|
+
return "localhost/api/kyc/notifications/aiprise";
|
|
25
27
|
case common_1.RioEnv.Development:
|
|
26
28
|
return "https://dev.riotransfer.co/api/kyc/notifications/aiprise";
|
|
27
29
|
case common_1.RioEnv.Sandbox:
|
|
@@ -34,6 +36,8 @@ class AiPriseClient {
|
|
|
34
36
|
};
|
|
35
37
|
this.getRedirectUrl = (rioEnv) => {
|
|
36
38
|
switch (rioEnv) {
|
|
39
|
+
case common_1.RioEnv.Local:
|
|
40
|
+
return "https://sandbox.riotransfer.co";
|
|
37
41
|
case common_1.RioEnv.Development:
|
|
38
42
|
return "https://dev.riotransfer.co";
|
|
39
43
|
case common_1.RioEnv.Sandbox:
|
|
@@ -29,7 +29,7 @@ class BitsoClient {
|
|
|
29
29
|
}
|
|
30
30
|
createClabe() {
|
|
31
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
if (
|
|
32
|
+
if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local].includes(process.env.RIO_ENV)) {
|
|
33
33
|
throw new Error("Bitso create clabe not allowed in sandbox");
|
|
34
34
|
}
|
|
35
35
|
const requestConfig = {
|
|
@@ -46,7 +46,7 @@ class BitsoClient {
|
|
|
46
46
|
}
|
|
47
47
|
createReceivingAccount(user, bankAccount, bitsoBankAccountCode) {
|
|
48
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
if (
|
|
49
|
+
if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local].includes(process.env.RIO_ENV)) {
|
|
50
50
|
throw new Error("Bitso create receiving account not allowed in sandbox");
|
|
51
51
|
}
|
|
52
52
|
const requestConfig = {
|
|
@@ -82,7 +82,7 @@ class BitsoClient {
|
|
|
82
82
|
}
|
|
83
83
|
createWithdraw(bitsoReceivingAccountId, amount, concept, rfc) {
|
|
84
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
if (
|
|
85
|
+
if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local].includes(process.env.RIO_ENV)) {
|
|
86
86
|
throw new Error("Bitso withdraw not allowed in sandbox");
|
|
87
87
|
}
|
|
88
88
|
const requestConfig = {
|
|
@@ -129,7 +129,7 @@ class BitsoClient {
|
|
|
129
129
|
}
|
|
130
130
|
createLimitOrder(asset, amount, price, side) {
|
|
131
131
|
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
-
if (
|
|
132
|
+
if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local].includes(process.env.RIO_ENV)) {
|
|
133
133
|
throw new Error("Bitso limit orders not allowed in sandbox");
|
|
134
134
|
}
|
|
135
135
|
const major = amount / price;
|
|
@@ -226,7 +226,7 @@ class BitsoClient {
|
|
|
226
226
|
}
|
|
227
227
|
cancelOrder(oid) {
|
|
228
228
|
return __awaiter(this, void 0, void 0, function* () {
|
|
229
|
-
if (
|
|
229
|
+
if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local].includes(process.env.RIO_ENV)) {
|
|
230
230
|
throw new Error("Bitso cancel order not allowed in sandbox");
|
|
231
231
|
}
|
|
232
232
|
const requestConfig = {
|
|
@@ -29,7 +29,7 @@ class BridgeClient {
|
|
|
29
29
|
}
|
|
30
30
|
createKYCLink(fullName, email, userType) {
|
|
31
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
if (
|
|
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
35
|
const { data } = yield axios_1.default.post(`${this.baseUrl}/v0/kyc_links`, {
|
|
@@ -57,7 +57,7 @@ class BridgeClient {
|
|
|
57
57
|
}
|
|
58
58
|
createTransfer(bridgeCustomerId, amountInUSD, source, destination, developerFee) {
|
|
59
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
if (
|
|
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
63
|
const { data } = yield axios_1.default.post(`${this.baseUrl}/v0/transfers`, {
|
|
@@ -107,7 +107,7 @@ class BridgeClient {
|
|
|
107
107
|
}
|
|
108
108
|
createLiquidationAddress(bridgeCustomerId, currency, chain, externalAccountId) {
|
|
109
109
|
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
-
if (
|
|
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
113
|
const { data } = yield axios_1.default.post(`${this.baseUrl}/v0/customers/${bridgeCustomerId}/liquidation_addresses`, {
|
|
@@ -157,7 +157,7 @@ class BridgeClient {
|
|
|
157
157
|
}
|
|
158
158
|
createPlaidLinkToken(bridgeCustomerId) {
|
|
159
159
|
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
-
if (
|
|
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
163
|
const { data } = yield axios_1.default.post(`${this.baseUrl}/v0/customers/${bridgeCustomerId}/plaid_link_requests`, undefined, {
|
|
@@ -192,7 +192,7 @@ class BridgeClient {
|
|
|
192
192
|
}
|
|
193
193
|
exchangePlaidPublicToken(linkToken, publicToken) {
|
|
194
194
|
return __awaiter(this, void 0, void 0, function* () {
|
|
195
|
-
if (
|
|
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
198
|
const { data } = yield axios_1.default.post(`${this.baseUrl}/v0/plaid_exchange_public_token/${linkToken}`, {
|
|
@@ -207,7 +207,7 @@ class BridgeClient {
|
|
|
207
207
|
}
|
|
208
208
|
createExternalAccount(bridgeCustomerId, bankName, accountNumber, routingNumber, accountOwnerName, address) {
|
|
209
209
|
return __awaiter(this, void 0, void 0, function* () {
|
|
210
|
-
if (
|
|
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
213
|
const { data } = yield axios_1.default.post(`${this.baseUrl}/v0/customers/${bridgeCustomerId}/external_accounts`, {
|
|
@@ -56,7 +56,7 @@ class FireblocksClient {
|
|
|
56
56
|
}
|
|
57
57
|
withdrawFromExchange(crypto, address, amountCrypto) {
|
|
58
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
if (
|
|
59
|
+
if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local].includes(process.env.RIO_ENV)) {
|
|
60
60
|
throw new Error("Withdrawals are disabled in sandbox mode.");
|
|
61
61
|
}
|
|
62
62
|
yield this.fireblocks.createTransaction({
|
|
@@ -78,7 +78,7 @@ class FireblocksClient {
|
|
|
78
78
|
}
|
|
79
79
|
withdrawFromVault(crypto, address, amountCrypto) {
|
|
80
80
|
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
-
if (
|
|
81
|
+
if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local].includes(process.env.RIO_ENV)) {
|
|
82
82
|
throw new Error("Withdrawals are disabled in sandbox mode.");
|
|
83
83
|
}
|
|
84
84
|
const response = yield this.fireblocks.createTransaction({
|
|
@@ -218,7 +218,7 @@ class FireblocksClient {
|
|
|
218
218
|
}
|
|
219
219
|
createVault(userId, name, type) {
|
|
220
220
|
return __awaiter(this, void 0, void 0, function* () {
|
|
221
|
-
if (
|
|
221
|
+
if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local].includes(process.env.RIO_ENV)) {
|
|
222
222
|
throw new Error("Vault creation is disabled in sandbox mode.");
|
|
223
223
|
}
|
|
224
224
|
const vault = yield this.fireblocks.createVaultAccount(`${name} - ${userId} - ${type}`, false, userId, true);
|
|
@@ -227,7 +227,7 @@ class FireblocksClient {
|
|
|
227
227
|
}
|
|
228
228
|
createWallet(vaultId, crypto) {
|
|
229
229
|
return __awaiter(this, void 0, void 0, function* () {
|
|
230
|
-
if (
|
|
230
|
+
if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local].includes(process.env.RIO_ENV)) {
|
|
231
231
|
throw new Error("Wallet creation is disabled in sandbox mode.");
|
|
232
232
|
}
|
|
233
233
|
const wallet = yield this.fireblocks.createVaultAsset(vaultId, crypto);
|
|
@@ -236,7 +236,7 @@ class FireblocksClient {
|
|
|
236
236
|
}
|
|
237
237
|
internalTransfer(crypto, sourceVaultId, destinationVaultId, amountCrypto, notes) {
|
|
238
238
|
return __awaiter(this, void 0, void 0, function* () {
|
|
239
|
-
if (
|
|
239
|
+
if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local].includes(process.env.RIO_ENV)) {
|
|
240
240
|
throw new Error("Internal transfers are disabled in sandbox mode.");
|
|
241
241
|
}
|
|
242
242
|
const response = yield this.fireblocks.createTransaction({
|
|
@@ -258,7 +258,7 @@ class FireblocksClient {
|
|
|
258
258
|
}
|
|
259
259
|
externalTransfer(crypto, sourceVaultId, destinationAddress, amountCrypto, notes) {
|
|
260
260
|
return __awaiter(this, void 0, void 0, function* () {
|
|
261
|
-
if (
|
|
261
|
+
if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local].includes(process.env.RIO_ENV)) {
|
|
262
262
|
throw new Error("External transfers are disabled in sandbox mode.");
|
|
263
263
|
}
|
|
264
264
|
const response = yield this.fireblocks.createTransaction({
|
|
@@ -282,7 +282,7 @@ class FireblocksClient {
|
|
|
282
282
|
}
|
|
283
283
|
transferToExchange(crypto, sourceVaultId, destinationExchangeId, amountCrypto, notes) {
|
|
284
284
|
return __awaiter(this, void 0, void 0, function* () {
|
|
285
|
-
if (
|
|
285
|
+
if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local].includes(process.env.RIO_ENV)) {
|
|
286
286
|
throw new Error("Transfers to exchanges are disabled in sandbox mode.");
|
|
287
287
|
}
|
|
288
288
|
const response = yield this.fireblocks.createTransaction({
|
|
@@ -304,7 +304,7 @@ class FireblocksClient {
|
|
|
304
304
|
}
|
|
305
305
|
transferFromExchange(crypto, sourceExchangeId, destinationVaultId, amountCrypto, notes) {
|
|
306
306
|
return __awaiter(this, void 0, void 0, function* () {
|
|
307
|
-
if (
|
|
307
|
+
if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local].includes(process.env.RIO_ENV)) {
|
|
308
308
|
throw new Error("Transfers from exchanges are disabled in sandbox mode.");
|
|
309
309
|
}
|
|
310
310
|
const response = yield this.fireblocks.createTransaction({
|
|
@@ -326,7 +326,7 @@ class FireblocksClient {
|
|
|
326
326
|
}
|
|
327
327
|
sweep(vaultId, assetId, amount) {
|
|
328
328
|
return __awaiter(this, void 0, void 0, function* () {
|
|
329
|
-
if (
|
|
329
|
+
if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local].includes(process.env.RIO_ENV)) {
|
|
330
330
|
throw new Error("Sweeps are disabled in sandbox mode.");
|
|
331
331
|
}
|
|
332
332
|
yield this.fireblocks.createTransaction({
|
|
@@ -26,7 +26,7 @@ class InvopopClient {
|
|
|
26
26
|
createJob(mongoose, order, user) {
|
|
27
27
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
28
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
if (
|
|
29
|
+
if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local].includes(process.env.RIO_ENV)) {
|
|
30
30
|
throw new Error("Cannot create invoice in sandbox environment");
|
|
31
31
|
}
|
|
32
32
|
const uuid = (0, uuid_1.v1)();
|
|
@@ -22,6 +22,16 @@ const secret_manager_client_1 = require("../clients/secret-manager-client");
|
|
|
22
22
|
const admin_auth_1 = require("../models/admin-auth");
|
|
23
23
|
const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
24
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
25
|
+
if (authorizationTypes.includes(common_1.AuthorizationType.GenesisAdmin)) {
|
|
26
|
+
let apiKey = req.header("x-api-key");
|
|
27
|
+
const GENESIS_ADMIN_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("GENESIS_ADMIN_KEY");
|
|
28
|
+
if (!GENESIS_ADMIN_KEY) {
|
|
29
|
+
throw new common_1.SecretManagerError();
|
|
30
|
+
}
|
|
31
|
+
if (apiKey === GENESIS_ADMIN_KEY) {
|
|
32
|
+
req.validGenisisAdminKey = true;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
25
35
|
if (authorizationTypes.includes(common_1.AuthorizationType.Cluster)) {
|
|
26
36
|
let apiKey = req.header("x-cluster-api-key");
|
|
27
37
|
const CLUSTER_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("CLUSTER_API_KEY");
|
|
@@ -129,6 +139,11 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
129
139
|
next();
|
|
130
140
|
return;
|
|
131
141
|
}
|
|
142
|
+
if (authorizationTypes.includes(common_1.AuthorizationType.GenesisAdmin) &&
|
|
143
|
+
req.validGenisisAdminKey) {
|
|
144
|
+
next();
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
132
147
|
if (authorizationTypes.includes(common_1.AuthorizationType.Auth) && req.auth) {
|
|
133
148
|
next();
|
|
134
149
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1559",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@google-cloud/storage": "^6.9.5",
|
|
29
29
|
"@google-cloud/vision": "^4.0.2",
|
|
30
30
|
"@hyperdx/node-opentelemetry": "^0.4.2",
|
|
31
|
-
"@riocrypto/common": "^1.0.
|
|
31
|
+
"@riocrypto/common": "^1.0.1397",
|
|
32
32
|
"@types/express": "^4.17.13",
|
|
33
33
|
"axios": "^1.6.0",
|
|
34
34
|
"ccxt": "^3.0.30",
|