@riocrypto/common-server 1.0.510 → 1.0.511
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/ccxt-client.d.ts +1 -4
- package/build/clients/ccxt-client.js +8 -9
- package/build/clients/fireblocks-client.d.ts +1 -1
- package/build/clients/fixer-client.d.ts +1 -1
- package/build/clients/kushki-client.d.ts +1 -3
- package/build/clients/kushki-client.js +3 -3
- package/build/clients/rio-client.d.ts +1 -21
- package/build/helpers/get-user-helper.d.ts +2 -3
- package/build/index.d.ts +0 -51
- package/build/index.js +0 -51
- package/build/middlewares/authorize.d.ts +1 -1
- package/build/middlewares/authorize.js +32 -41
- package/build/middlewares/error-handler.js +2 -2
- package/build/middlewares/get-order.js +7 -9
- package/build/middlewares/get-user.js +3 -3
- package/build/middlewares/require-admin-api-key.js +2 -2
- package/build/middlewares/require-auth.js +2 -2
- package/build/middlewares/require-priveleges.js +3 -4
- package/build/middlewares/validate-auth.js +4 -5
- package/build/middlewares/validate-kyc.js +7 -9
- package/build/middlewares/validate-request.js +2 -2
- package/build/models/auth.d.ts +1 -2
- package/build/models/business-user.d.ts +1 -7
- package/build/models/checked-address.d.ts +1 -1
- package/build/models/order.d.ts +1 -11
- package/build/models/partner.d.ts +1 -1
- package/build/models/user.d.ts +1 -6
- package/package.json +2 -1
- package/build/errors/address-check-failed-error.d.ts +0 -8
- package/build/errors/address-check-failed-error.js +0 -15
- package/build/errors/admin-already-exists-error.d.ts +0 -8
- package/build/errors/admin-already-exists-error.js +0 -15
- package/build/errors/admin-not-found-error.d.ts +0 -8
- package/build/errors/admin-not-found-error.js +0 -15
- package/build/errors/admin-only-error.d.ts +0 -8
- package/build/errors/admin-only-error.js +0 -15
- package/build/errors/api-key-not-found-error.d.ts +0 -8
- package/build/errors/api-key-not-found-error.js +0 -15
- package/build/errors/auth-already-exists-error.d.ts +0 -8
- package/build/errors/auth-already-exists-error.js +0 -15
- package/build/errors/auth-not-found-error.d.ts +0 -8
- package/build/errors/auth-not-found-error.js +0 -15
- package/build/errors/authorization-failed-error.d.ts +0 -8
- package/build/errors/authorization-failed-error.js +0 -15
- package/build/errors/custom-error.d.ts +0 -8
- package/build/errors/custom-error.js +0 -10
- package/build/errors/database-connection-error.d.ts +0 -9
- package/build/errors/database-connection-error.js +0 -16
- package/build/errors/insufficient-liquidity-error.d.ts +0 -8
- package/build/errors/insufficient-liquidity-error.js +0 -19
- package/build/errors/invalid-order-size-error.d.ts +0 -8
- package/build/errors/invalid-order-size-error.js +0 -15
- package/build/errors/message-failed-error.d.ts +0 -8
- package/build/errors/message-failed-error.js +0 -15
- package/build/errors/missing-kyc-approval-error.d.ts +0 -8
- package/build/errors/missing-kyc-approval-error.js +0 -15
- package/build/errors/missing-password-error.d.ts +0 -8
- package/build/errors/missing-password-error.js +0 -15
- package/build/errors/missing-security-question-error.d.ts +0 -8
- package/build/errors/missing-security-question-error.js +0 -15
- package/build/errors/missing-user-error.d.ts +0 -8
- package/build/errors/missing-user-error.js +0 -15
- package/build/errors/not-authorized-error.d.ts +0 -8
- package/build/errors/not-authorized-error.js +0 -15
- package/build/errors/not-broker-error.d.ts +0 -8
- package/build/errors/not-broker-error.js +0 -17
- package/build/errors/not-found-error.d.ts +0 -8
- package/build/errors/not-found-error.js +0 -15
- package/build/errors/partner-already-exists-error.d.ts +0 -8
- package/build/errors/partner-already-exists-error.js +0 -15
- package/build/errors/partner-not-found-error.d.ts +0 -8
- package/build/errors/partner-not-found-error.js +0 -15
- package/build/errors/password-already-used-error.d.ts +0 -8
- package/build/errors/password-already-used-error.js +0 -15
- package/build/errors/request-validation-error.d.ts +0 -11
- package/build/errors/request-validation-error.js +0 -18
- package/build/errors/rio-settings-already-exists-error.d.ts +0 -8
- package/build/errors/rio-settings-already-exists-error.js +0 -15
- package/build/errors/rio-settings-not-found-error.d.ts +0 -8
- package/build/errors/rio-settings-not-found-error.js +0 -15
- package/build/errors/user-already-exists-error.d.ts +0 -8
- package/build/errors/user-already-exists-error.js +0 -15
- package/build/errors/verification-failed-error.d.ts +0 -8
- package/build/errors/verification-failed-error.js +0 -15
- package/build/errors/wrong-order-state-error.d.ts +0 -8
- package/build/errors/wrong-order-state-error.js +0 -17
- package/build/errors/wrong-password-error.d.ts +0 -8
- package/build/errors/wrong-password-error.js +0 -15
- package/build/errors/wrong-processor-error.d.ts +0 -8
- package/build/errors/wrong-processor-error.js +0 -15
- package/build/errors/wrong-security-answer-error.d.ts +0 -8
- package/build/errors/wrong-security-answer-error.js +0 -15
- package/build/events/admin-created-event.d.ts +0 -8
- package/build/events/admin-created-event.js +0 -2
- package/build/events/admin-deleted-event.d.ts +0 -7
- package/build/events/admin-deleted-event.js +0 -2
- package/build/events/bank-payout-initialized-event.d.ts +0 -12
- package/build/events/bank-payout-initialized-event.js +0 -2
- package/build/events/base-listener.d.ts +0 -18
- package/build/events/base-listener.js +0 -30
- package/build/events/base-publisher.d.ts +0 -13
- package/build/events/base-publisher.js +0 -20
- package/build/events/business-kyc-failed-event.d.ts +0 -7
- package/build/events/business-kyc-failed-event.js +0 -2
- package/build/events/business-kyc-passed-event.d.ts +0 -7
- package/build/events/business-kyc-passed-event.js +0 -2
- package/build/events/checked-address-created-event.d.ts +0 -11
- package/build/events/checked-address-created-event.js +0 -2
- package/build/events/checked-address-updated-event.d.ts +0 -10
- package/build/events/checked-address-updated-event.js +0 -2
- package/build/events/clip-card-payment-created-event.d.ts +0 -8
- package/build/events/clip-card-payment-created-event.js +0 -2
- package/build/events/clip-card-payment-failed-event.d.ts +0 -7
- package/build/events/clip-card-payment-failed-event.js +0 -2
- package/build/events/deposit-address-created-event.d.ts +0 -8
- package/build/events/deposit-address-created-event.js +0 -2
- package/build/events/deposit-address-failed-event.d.ts +0 -7
- package/build/events/deposit-address-failed-event.js +0 -2
- package/build/events/deposit-completed-event.d.ts +0 -9
- package/build/events/deposit-completed-event.js +0 -2
- package/build/events/deposit-registered-event.d.ts +0 -9
- package/build/events/deposit-registered-event.js +0 -2
- package/build/events/dlocal-bank-payment-created-event.d.ts +0 -9
- package/build/events/dlocal-bank-payment-created-event.js +0 -2
- package/build/events/dlocal-bank-payment-failed-event.d.ts +0 -7
- package/build/events/dlocal-bank-payment-failed-event.js +0 -2
- package/build/events/fees-failed-event.d.ts +0 -7
- package/build/events/fees-failed-event.js +0 -2
- package/build/events/kyc-failed-event.d.ts +0 -7
- package/build/events/kyc-failed-event.js +0 -2
- package/build/events/kyc-passed-event.d.ts +0 -7
- package/build/events/kyc-passed-event.js +0 -2
- package/build/events/liquidity-fill-failed-event.d.ts +0 -7
- package/build/events/liquidity-fill-failed-event.js +0 -2
- package/build/events/liquidity-filled-event.d.ts +0 -11
- package/build/events/liquidity-filled-event.js +0 -2
- package/build/events/liquidity-routed-event.d.ts +0 -9
- package/build/events/liquidity-routed-event.js +0 -2
- package/build/events/liquidity-routing-failed-event.d.ts +0 -7
- package/build/events/liquidity-routing-failed-event.js +0 -2
- package/build/events/liquidity-transfer-failed-event.d.ts +0 -7
- package/build/events/liquidity-transfer-failed-event.js +0 -2
- package/build/events/liquidity-transfered-event.d.ts +0 -9
- package/build/events/liquidity-transfered-event.js +0 -2
- package/build/events/order-created-event.d.ts +0 -39
- package/build/events/order-created-event.js +0 -2
- package/build/events/order-deleted-event.d.ts +0 -7
- package/build/events/order-deleted-event.js +0 -2
- package/build/events/order-updated-event.d.ts +0 -37
- package/build/events/order-updated-event.js +0 -2
- package/build/events/partner-created-event.d.ts +0 -14
- package/build/events/partner-created-event.js +0 -2
- package/build/events/partner-updated-event.d.ts +0 -19
- package/build/events/partner-updated-event.js +0 -2
- package/build/events/payment-complete-event.d.ts +0 -9
- package/build/events/payment-complete-event.js +0 -2
- package/build/events/payment-created-event.d.ts +0 -8
- package/build/events/payment-created-event.js +0 -2
- package/build/events/payment-failed-event.d.ts +0 -7
- package/build/events/payment-failed-event.js +0 -2
- package/build/events/processor-routed-event.d.ts +0 -9
- package/build/events/processor-routed-event.js +0 -2
- package/build/events/processor-routing-failed-event.d.ts +0 -7
- package/build/events/processor-routing-failed-event.js +0 -2
- package/build/events/quote-failed-event.d.ts +0 -7
- package/build/events/quote-failed-event.js +0 -2
- package/build/events/rio-settings-created-event.d.ts +0 -8
- package/build/events/rio-settings-created-event.js +0 -2
- package/build/events/rio-settings-updated-event.d.ts +0 -8
- package/build/events/rio-settings-updated-event.js +0 -2
- package/build/events/subjects.d.ts +0 -60
- package/build/events/subjects.js +0 -64
- package/build/events/user-created-event.d.ts +0 -25
- package/build/events/user-created-event.js +0 -2
- package/build/events/user-deleted-event.d.ts +0 -7
- package/build/events/user-deleted-event.js +0 -2
- package/build/events/user-disabled-event.d.ts +0 -7
- package/build/events/user-disabled-event.js +0 -2
- package/build/events/user-updated-event.d.ts +0 -23
- package/build/events/user-updated-event.js +0 -2
- package/build/events/wyre-ach-payment-created-event.d.ts +0 -9
- package/build/events/wyre-ach-payment-created-event.js +0 -2
- package/build/events/wyre-payment-method-created-event.d.ts +0 -11
- package/build/events/wyre-payment-method-created-event.js +0 -2
- package/build/events/wyre-transfer-completed-event.d.ts +0 -9
- package/build/events/wyre-transfer-completed-event.js +0 -2
- package/build/events/wyre-transfer-created-event.d.ts +0 -9
- package/build/events/wyre-transfer-created-event.js +0 -2
- package/build/events/wyre-transfer-failed-event.d.ts +0 -9
- package/build/events/wyre-transfer-failed-event.js +0 -2
- package/build/events/wyre-user-created-event.d.ts +0 -9
- package/build/events/wyre-user-created-event.js +0 -2
- package/build/types/address-check-result.d.ts +0 -4
- package/build/types/address-check-result.js +0 -8
- package/build/types/admin.d.ts +0 -4
- package/build/types/admin.js +0 -2
- package/build/types/api-key.d.ts +0 -5
- package/build/types/api-key.js +0 -2
- package/build/types/auth-update.d.ts +0 -8
- package/build/types/auth-update.js +0 -2
- package/build/types/auth.d.ts +0 -6
- package/build/types/auth.js +0 -2
- package/build/types/authorization-type.d.ts +0 -9
- package/build/types/authorization-type.js +0 -13
- package/build/types/bank-payout.d.ts +0 -7
- package/build/types/bank-payout.js +0 -2
- package/build/types/business-user-input.d.ts +0 -27
- package/build/types/business-user-input.js +0 -2
- package/build/types/business-user-update.d.ts +0 -26
- package/build/types/business-user-update.js +0 -2
- package/build/types/business-user.d.ts +0 -30
- package/build/types/business-user.js +0 -2
- package/build/types/ccxt-liquidity-provider.d.ts +0 -5
- package/build/types/ccxt-liquidity-provider.js +0 -9
- package/build/types/checked-address.d.ts +0 -7
- package/build/types/checked-address.js +0 -2
- package/build/types/clip-payment-status.d.ts +0 -3
- package/build/types/clip-payment-status.js +0 -7
- package/build/types/country.d.ts +0 -57
- package/build/types/country.js +0 -256
- package/build/types/crypto.d.ts +0 -6
- package/build/types/crypto.js +0 -38
- package/build/types/dlocal-payment-method.d.ts +0 -4
- package/build/types/dlocal-payment-method.js +0 -8
- package/build/types/fees.d.ts +0 -9
- package/build/types/fees.js +0 -2
- package/build/types/fiat.d.ts +0 -6
- package/build/types/fiat.js +0 -45
- package/build/types/kyc-status.d.ts +0 -7
- package/build/types/kyc-status.js +0 -11
- package/build/types/language.d.ts +0 -6
- package/build/types/language.js +0 -10
- package/build/types/liquidity-provider.d.ts +0 -9
- package/build/types/liquidity-provider.js +0 -13
- package/build/types/order-input.d.ts +0 -31
- package/build/types/order-input.js +0 -2
- package/build/types/order-status.d.ts +0 -21
- package/build/types/order-status.js +0 -51
- package/build/types/order.d.ts +0 -37
- package/build/types/order.js +0 -2
- package/build/types/partner-auth.d.ts +0 -5
- package/build/types/partner-auth.js +0 -2
- package/build/types/partner-stats.d.ts +0 -5
- package/build/types/partner-stats.js +0 -2
- package/build/types/partner-status.d.ts +0 -6
- package/build/types/partner-status.js +0 -10
- package/build/types/partner-update.d.ts +0 -10
- package/build/types/partner-update.js +0 -2
- package/build/types/partner.d.ts +0 -15
- package/build/types/partner.js +0 -2
- package/build/types/payment-method.d.ts +0 -5
- package/build/types/payment-method.js +0 -9
- package/build/types/payout-method.d.ts +0 -3
- package/build/types/payout-method.js +0 -7
- package/build/types/platform-fee-range.d.ts +0 -5
- package/build/types/platform-fee-range.js +0 -2
- package/build/types/processor.d.ts +0 -12
- package/build/types/processor.js +0 -16
- package/build/types/quote.d.ts +0 -21
- package/build/types/quote.js +0 -2
- package/build/types/rio-env.d.ts +0 -6
- package/build/types/rio-env.js +0 -10
- package/build/types/rio-settings-update.d.ts +0 -4
- package/build/types/rio-settings-update.js +0 -2
- package/build/types/rio-settings.d.ts +0 -4
- package/build/types/rio-settings.js +0 -2
- package/build/types/security-question.d.ts +0 -7
- package/build/types/security-question.js +0 -11
- package/build/types/side.d.ts +0 -4
- package/build/types/side.js +0 -8
- package/build/types/us-state.d.ts +0 -61
- package/build/types/us-state.js +0 -65
- package/build/types/user-attribute.d.ts +0 -10
- package/build/types/user-attribute.js +0 -14
- package/build/types/user-input.d.ts +0 -26
- package/build/types/user-input.js +0 -2
- package/build/types/user-type.d.ts +0 -4
- package/build/types/user-type.js +0 -8
- package/build/types/user-update.d.ts +0 -25
- package/build/types/user-update.js +0 -2
- package/build/types/user.d.ts +0 -30
- package/build/types/user.js +0 -2
- package/build/types/users-stats.d.ts +0 -3
- package/build/types/users-stats.js +0 -2
- package/build/types/wyre-address.d.ts +0 -9
- package/build/types/wyre-address.js +0 -2
- package/build/types/wyre-order-status.d.ts +0 -7
- package/build/types/wyre-order-status.js +0 -11
- package/build/types/wyre-payment-method.d.ts +0 -40
- package/build/types/wyre-payment-method.js +0 -2
- package/build/types/wyre-webhook-notification.d.ts +0 -12
- package/build/types/wyre-webhook-notification.js +0 -2
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CCXTLiquidityProvider } from "../types/ccxt-liquidity-provider";
|
|
3
|
-
import { Fiat } from "../types/fiat";
|
|
4
|
-
import { Side } from "../types/side";
|
|
1
|
+
import { CCXTLiquidityProvider, Fiat, Side } from "@riocrypto/common";
|
|
5
2
|
declare class CCXTClient {
|
|
6
3
|
private env;
|
|
7
4
|
constructor(env: "production" | "development");
|
|
@@ -13,9 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.ccxtWrapper = void 0;
|
|
16
|
+
const common_1 = require("@riocrypto/common");
|
|
16
17
|
const ccxt_1 = __importDefault(require("ccxt"));
|
|
17
|
-
const ccxt_liquidity_provider_1 = require("../types/ccxt-liquidity-provider");
|
|
18
|
-
const side_1 = require("../types/side");
|
|
19
18
|
class CCXTClient {
|
|
20
19
|
constructor(env) {
|
|
21
20
|
this.env = env;
|
|
@@ -32,7 +31,7 @@ class CCXTClient {
|
|
|
32
31
|
amountFiat: amount,
|
|
33
32
|
crypto,
|
|
34
33
|
fiat,
|
|
35
|
-
side:
|
|
34
|
+
side: common_1.Side.Buy,
|
|
36
35
|
};
|
|
37
36
|
}
|
|
38
37
|
else {
|
|
@@ -43,7 +42,7 @@ class CCXTClient {
|
|
|
43
42
|
amountFiat: amount,
|
|
44
43
|
crypto,
|
|
45
44
|
fiat,
|
|
46
|
-
side:
|
|
45
|
+
side: common_1.Side.Buy,
|
|
47
46
|
};
|
|
48
47
|
}
|
|
49
48
|
});
|
|
@@ -60,7 +59,7 @@ class CCXTClient {
|
|
|
60
59
|
amountFiat: order.amount * order.price,
|
|
61
60
|
crypto,
|
|
62
61
|
fiat,
|
|
63
|
-
side:
|
|
62
|
+
side: common_1.Side.Sell,
|
|
64
63
|
};
|
|
65
64
|
}
|
|
66
65
|
else {
|
|
@@ -71,7 +70,7 @@ class CCXTClient {
|
|
|
71
70
|
amountFiat: amount,
|
|
72
71
|
crypto,
|
|
73
72
|
fiat,
|
|
74
|
-
side:
|
|
73
|
+
side: common_1.Side.Sell,
|
|
75
74
|
};
|
|
76
75
|
}
|
|
77
76
|
});
|
|
@@ -80,7 +79,7 @@ class CCXTClient {
|
|
|
80
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
81
80
|
if (this.env === "production") {
|
|
82
81
|
const exchange = yield this.getExchange(ccxtLiquidityProvider);
|
|
83
|
-
const params = ccxtLiquidityProvider ===
|
|
82
|
+
const params = ccxtLiquidityProvider === common_1.CCXTLiquidityProvider.Kraken
|
|
84
83
|
? {
|
|
85
84
|
key: "Metamask",
|
|
86
85
|
}
|
|
@@ -104,7 +103,7 @@ class CCXTClient {
|
|
|
104
103
|
amountFiat: amount,
|
|
105
104
|
crypto,
|
|
106
105
|
fiat,
|
|
107
|
-
side:
|
|
106
|
+
side: common_1.Side.Buy,
|
|
108
107
|
};
|
|
109
108
|
}
|
|
110
109
|
else {
|
|
@@ -114,7 +113,7 @@ class CCXTClient {
|
|
|
114
113
|
amountFiat: amount,
|
|
115
114
|
crypto,
|
|
116
115
|
fiat,
|
|
117
|
-
side:
|
|
116
|
+
side: common_1.Side.Buy,
|
|
118
117
|
};
|
|
119
118
|
}
|
|
120
119
|
});
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { BusinessUser } from "
|
|
2
|
-
import { Order } from "../types/order";
|
|
3
|
-
import { User } from "../types/user";
|
|
1
|
+
import { BusinessUser, Order, User } from "@riocrypto/common";
|
|
4
2
|
declare class KushkiClient {
|
|
5
3
|
private privateMerchantId;
|
|
6
4
|
private environment;
|
|
@@ -13,8 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.kushkiClient = void 0;
|
|
16
|
+
const common_1 = require("@riocrypto/common");
|
|
16
17
|
const axios_1 = __importDefault(require("axios"));
|
|
17
|
-
const user_type_1 = require("../types/user-type");
|
|
18
18
|
class KushkiClient {
|
|
19
19
|
constructor(privateMerchantId, environment) {
|
|
20
20
|
this.privateMerchantId = privateMerchantId;
|
|
@@ -93,7 +93,7 @@ class KushkiClient {
|
|
|
93
93
|
iva: 0,
|
|
94
94
|
},
|
|
95
95
|
callbackUrl: "https://riocrypto.com",
|
|
96
|
-
userType: user.type ===
|
|
96
|
+
userType: user.type === common_1.UserType.Business ? 1 : 0,
|
|
97
97
|
documentType: "CC",
|
|
98
98
|
documentNumber: "123456789",
|
|
99
99
|
paymentDescription: `Compra de ${order.crypto} en riocrypto.com`,
|
|
@@ -124,7 +124,7 @@ class KushkiClient {
|
|
|
124
124
|
iva: 0,
|
|
125
125
|
},
|
|
126
126
|
contactDetails: {
|
|
127
|
-
fullName: user.type ===
|
|
127
|
+
fullName: user.type === common_1.UserType.Business
|
|
128
128
|
? user.companyName
|
|
129
129
|
: `${user.firstName} ${user.lastName}`,
|
|
130
130
|
email: user.email,
|
|
@@ -1,25 +1,5 @@
|
|
|
1
|
+
import { Admin, Auth, AuthUpdate, BankPayout, BusinessUser, BusinessUserInput, BusinessUserUpdate, CheckedAddress, Country, Fiat, Order, OrderInput, Partner, PaymentMethod, PayoutMethod, RioSettings, RioSettingsUpdate, SecurityQuestion, User, UserInput, UserUpdate } from "@riocrypto/common";
|
|
1
2
|
import { AxiosInstance, AxiosStatic } from "axios";
|
|
2
|
-
import { Admin } from "../types/admin";
|
|
3
|
-
import { Auth } from "../types/auth";
|
|
4
|
-
import { AuthUpdate } from "../types/auth-update";
|
|
5
|
-
import { BankPayout } from "../types/bank-payout";
|
|
6
|
-
import { BusinessUser } from "../types/business-user";
|
|
7
|
-
import { BusinessUserInput } from "../types/business-user-input";
|
|
8
|
-
import { BusinessUserUpdate } from "../types/business-user-update";
|
|
9
|
-
import { CheckedAddress } from "../types/checked-address";
|
|
10
|
-
import { Country } from "../types/country";
|
|
11
|
-
import { Fiat } from "../types/fiat";
|
|
12
|
-
import { Order } from "../types/order";
|
|
13
|
-
import { OrderInput } from "../types/order-input";
|
|
14
|
-
import { Partner } from "../types/partner";
|
|
15
|
-
import { PaymentMethod } from "../types/payment-method";
|
|
16
|
-
import { PayoutMethod } from "../types/payout-method";
|
|
17
|
-
import { RioSettings } from "../types/rio-settings";
|
|
18
|
-
import { RioSettingsUpdate } from "../types/rio-settings-update";
|
|
19
|
-
import { SecurityQuestion } from "../types/security-question";
|
|
20
|
-
import { User } from "../types/user";
|
|
21
|
-
import { UserInput } from "../types/user-input";
|
|
22
|
-
import { UserUpdate } from "../types/user-update";
|
|
23
3
|
export declare class RioClient {
|
|
24
4
|
private axios;
|
|
25
5
|
constructor(axios: AxiosStatic | AxiosInstance);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { Mongoose } from "mongoose";
|
|
2
|
-
import { User as UserType } from "
|
|
3
|
-
|
|
4
|
-
export declare const getUserHelper: (id: string, mongoose: Mongoose) => Promise<BusinessUserType | UserType | null>;
|
|
2
|
+
import { User as UserType, BusinessUser as BusinessUserType } from "@riocrypto/common";
|
|
3
|
+
export declare const getUserHelper: (id: string, mongoose: Mongoose) => Promise<UserType | BusinessUserType | null>;
|
package/build/index.d.ts
CHANGED
|
@@ -12,57 +12,6 @@ export * from "./middlewares/get-user";
|
|
|
12
12
|
export * from "./middlewares/require-priveleges";
|
|
13
13
|
export * from "./middlewares/validate-kyc";
|
|
14
14
|
export * from "./middlewares/authorize";
|
|
15
|
-
export * from "./events/base-listener";
|
|
16
|
-
export * from "./events/base-publisher";
|
|
17
|
-
export * from "./events/subjects";
|
|
18
|
-
export * from "./events/user-created-event";
|
|
19
|
-
export * from "./events/user-updated-event";
|
|
20
|
-
export * from "./events/user-deleted-event";
|
|
21
|
-
export * from "./events/user-disabled-event";
|
|
22
|
-
export * from "./events/order-created-event";
|
|
23
|
-
export * from "./events/order-updated-event";
|
|
24
|
-
export * from "./events/order-deleted-event";
|
|
25
|
-
export * from "./events/processor-routed-event";
|
|
26
|
-
export * from "./events/liquidity-routed-event";
|
|
27
|
-
export * from "./events/liquidity-filled-event";
|
|
28
|
-
export * from "./events/liquidity-transfered-event";
|
|
29
|
-
export * from "./events/liquidity-fill-failed-event";
|
|
30
|
-
export * from "./events/liquidity-transfer-failed-event";
|
|
31
|
-
export * from "./events/wyre-user-created-event";
|
|
32
|
-
export * from "./events/wyre-transfer-created-event";
|
|
33
|
-
export * from "./events/wyre-transfer-completed-event";
|
|
34
|
-
export * from "./events/wyre-transfer-failed-event";
|
|
35
|
-
export * from "./events/wyre-payment-method-created-event";
|
|
36
|
-
export * from "./events/wyre-ach-payment-created-event";
|
|
37
|
-
export * from "./events/kyc-passed-event";
|
|
38
|
-
export * from "./events/dlocal-bank-payment-created-event";
|
|
39
|
-
export * from "./events/dlocal-bank-payment-failed-event";
|
|
40
|
-
export * from "./events/partner-created-event";
|
|
41
|
-
export * from "./events/partner-updated-event";
|
|
42
|
-
export * from "./events/admin-created-event";
|
|
43
|
-
export * from "./events/clip-card-payment-created-event";
|
|
44
|
-
export * from "./events/clip-card-payment-failed-event";
|
|
45
|
-
export * from "./events/payment-complete-event";
|
|
46
|
-
export * from "./events/payment-created-event";
|
|
47
|
-
export * from "./events/payment-failed-event";
|
|
48
|
-
export * from "./events/rio-settings-created-event";
|
|
49
|
-
export * from "./events/rio-settings-updated-event";
|
|
50
|
-
export * from "./events/admin-deleted-event";
|
|
51
|
-
export * from "./events/deposit-registered-event";
|
|
52
|
-
export * from "./events/deposit-completed-event";
|
|
53
|
-
export * from "./events/deposit-address-created-event";
|
|
54
|
-
export * from "./events/bank-payout-initialized-event";
|
|
55
|
-
export * from "./events/quote-failed-event";
|
|
56
|
-
export * from "./events/processor-routing-failed-event";
|
|
57
|
-
export * from "./events/liquidity-routing-failed-event";
|
|
58
|
-
export * from "./events/fees-failed-event";
|
|
59
|
-
export * from "./events/deposit-address-failed-event";
|
|
60
|
-
export * from "./events/checked-address-created-event";
|
|
61
|
-
export * from "./events/checked-address-updated-event";
|
|
62
|
-
export * from "./events/kyc-passed-event";
|
|
63
|
-
export * from "./events/kyc-failed-event";
|
|
64
|
-
export * from "./events/business-kyc-passed-event";
|
|
65
|
-
export * from "./events/business-kyc-failed-event";
|
|
66
15
|
export * from "./services/apiKey";
|
|
67
16
|
export * from "./services/password";
|
|
68
17
|
export * from "./services/s3";
|
package/build/index.js
CHANGED
|
@@ -28,57 +28,6 @@ __exportStar(require("./middlewares/get-user"), exports);
|
|
|
28
28
|
__exportStar(require("./middlewares/require-priveleges"), exports);
|
|
29
29
|
__exportStar(require("./middlewares/validate-kyc"), exports);
|
|
30
30
|
__exportStar(require("./middlewares/authorize"), exports);
|
|
31
|
-
__exportStar(require("./events/base-listener"), exports);
|
|
32
|
-
__exportStar(require("./events/base-publisher"), exports);
|
|
33
|
-
__exportStar(require("./events/subjects"), exports);
|
|
34
|
-
__exportStar(require("./events/user-created-event"), exports);
|
|
35
|
-
__exportStar(require("./events/user-updated-event"), exports);
|
|
36
|
-
__exportStar(require("./events/user-deleted-event"), exports);
|
|
37
|
-
__exportStar(require("./events/user-disabled-event"), exports);
|
|
38
|
-
__exportStar(require("./events/order-created-event"), exports);
|
|
39
|
-
__exportStar(require("./events/order-updated-event"), exports);
|
|
40
|
-
__exportStar(require("./events/order-deleted-event"), exports);
|
|
41
|
-
__exportStar(require("./events/processor-routed-event"), exports);
|
|
42
|
-
__exportStar(require("./events/liquidity-routed-event"), exports);
|
|
43
|
-
__exportStar(require("./events/liquidity-filled-event"), exports);
|
|
44
|
-
__exportStar(require("./events/liquidity-transfered-event"), exports);
|
|
45
|
-
__exportStar(require("./events/liquidity-fill-failed-event"), exports);
|
|
46
|
-
__exportStar(require("./events/liquidity-transfer-failed-event"), exports);
|
|
47
|
-
__exportStar(require("./events/wyre-user-created-event"), exports);
|
|
48
|
-
__exportStar(require("./events/wyre-transfer-created-event"), exports);
|
|
49
|
-
__exportStar(require("./events/wyre-transfer-completed-event"), exports);
|
|
50
|
-
__exportStar(require("./events/wyre-transfer-failed-event"), exports);
|
|
51
|
-
__exportStar(require("./events/wyre-payment-method-created-event"), exports);
|
|
52
|
-
__exportStar(require("./events/wyre-ach-payment-created-event"), exports);
|
|
53
|
-
__exportStar(require("./events/kyc-passed-event"), exports);
|
|
54
|
-
__exportStar(require("./events/dlocal-bank-payment-created-event"), exports);
|
|
55
|
-
__exportStar(require("./events/dlocal-bank-payment-failed-event"), exports);
|
|
56
|
-
__exportStar(require("./events/partner-created-event"), exports);
|
|
57
|
-
__exportStar(require("./events/partner-updated-event"), exports);
|
|
58
|
-
__exportStar(require("./events/admin-created-event"), exports);
|
|
59
|
-
__exportStar(require("./events/clip-card-payment-created-event"), exports);
|
|
60
|
-
__exportStar(require("./events/clip-card-payment-failed-event"), exports);
|
|
61
|
-
__exportStar(require("./events/payment-complete-event"), exports);
|
|
62
|
-
__exportStar(require("./events/payment-created-event"), exports);
|
|
63
|
-
__exportStar(require("./events/payment-failed-event"), exports);
|
|
64
|
-
__exportStar(require("./events/rio-settings-created-event"), exports);
|
|
65
|
-
__exportStar(require("./events/rio-settings-updated-event"), exports);
|
|
66
|
-
__exportStar(require("./events/admin-deleted-event"), exports);
|
|
67
|
-
__exportStar(require("./events/deposit-registered-event"), exports);
|
|
68
|
-
__exportStar(require("./events/deposit-completed-event"), exports);
|
|
69
|
-
__exportStar(require("./events/deposit-address-created-event"), exports);
|
|
70
|
-
__exportStar(require("./events/bank-payout-initialized-event"), exports);
|
|
71
|
-
__exportStar(require("./events/quote-failed-event"), exports);
|
|
72
|
-
__exportStar(require("./events/processor-routing-failed-event"), exports);
|
|
73
|
-
__exportStar(require("./events/liquidity-routing-failed-event"), exports);
|
|
74
|
-
__exportStar(require("./events/fees-failed-event"), exports);
|
|
75
|
-
__exportStar(require("./events/deposit-address-failed-event"), exports);
|
|
76
|
-
__exportStar(require("./events/checked-address-created-event"), exports);
|
|
77
|
-
__exportStar(require("./events/checked-address-updated-event"), exports);
|
|
78
|
-
__exportStar(require("./events/kyc-passed-event"), exports);
|
|
79
|
-
__exportStar(require("./events/kyc-failed-event"), exports);
|
|
80
|
-
__exportStar(require("./events/business-kyc-passed-event"), exports);
|
|
81
|
-
__exportStar(require("./events/business-kyc-failed-event"), exports);
|
|
82
31
|
__exportStar(require("./services/apiKey"), exports);
|
|
83
32
|
__exportStar(require("./services/password"), exports);
|
|
84
33
|
__exportStar(require("./services/s3"), exports);
|
|
@@ -2,8 +2,8 @@ import { Request, Response, NextFunction } from "express";
|
|
|
2
2
|
import { BusinessUserDoc } from "../models/business-user";
|
|
3
3
|
import { UserDoc } from "../models/user";
|
|
4
4
|
import { Mongoose } from "mongoose";
|
|
5
|
-
import { AuthorizationType } from "../types/authorization-type";
|
|
6
5
|
import { PartnerDoc } from "../models/partner";
|
|
6
|
+
import { AuthorizationType } from "@riocrypto/common";
|
|
7
7
|
interface AuthPayload {
|
|
8
8
|
id: string;
|
|
9
9
|
phoneNumber: string;
|
|
@@ -15,32 +15,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.authorize = void 0;
|
|
16
16
|
const business_user_1 = require("../models/business-user");
|
|
17
17
|
const user_1 = require("../models/user");
|
|
18
|
-
const user_attribute_1 = require("../types/user-attribute");
|
|
19
|
-
const authorization_type_1 = require("../types/authorization-type");
|
|
20
18
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
21
|
-
const not_authorized_error_1 = require("../errors/not-authorized-error");
|
|
22
|
-
const kyc_status_1 = require("../types/kyc-status");
|
|
23
|
-
const missing_kyc_approval_error_1 = require("../errors/missing-kyc-approval-error");
|
|
24
|
-
const missing_user_error_1 = require("../errors/missing-user-error");
|
|
25
|
-
const missing_password_error_1 = require("../errors/missing-password-error");
|
|
26
|
-
const missing_security_question_error_1 = require("../errors/missing-security-question-error");
|
|
27
|
-
const admin_only_error_1 = require("../errors/admin-only-error");
|
|
28
|
-
const not_broker_error_1 = require("../errors/not-broker-error");
|
|
29
19
|
const partner_1 = require("../models/partner");
|
|
20
|
+
const common_1 = require("@riocrypto/common");
|
|
30
21
|
const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
22
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
32
23
|
let missingKYC = false;
|
|
33
|
-
if (authorizationTypes.includes(
|
|
24
|
+
if (authorizationTypes.includes(common_1.AuthorizationType.AdminAPI)) {
|
|
34
25
|
let apiKey = req.header("x-api-key");
|
|
35
26
|
if (apiKey === process.env.ORIGINAL_ADMIN_API_KEY) {
|
|
36
27
|
req.validAdminApiKey = true;
|
|
37
28
|
}
|
|
38
29
|
}
|
|
39
|
-
if (authorizationTypes.includes(
|
|
40
|
-
authorizationTypes.includes(
|
|
41
|
-
authorizationTypes.includes(
|
|
42
|
-
authorizationTypes.includes(
|
|
43
|
-
authorizationTypes.includes(
|
|
30
|
+
if (authorizationTypes.includes(common_1.AuthorizationType.Auth) ||
|
|
31
|
+
authorizationTypes.includes(common_1.AuthorizationType.UserNoKYC) ||
|
|
32
|
+
authorizationTypes.includes(common_1.AuthorizationType.User) ||
|
|
33
|
+
authorizationTypes.includes(common_1.AuthorizationType.Broker) ||
|
|
34
|
+
authorizationTypes.includes(common_1.AuthorizationType.Partner)) {
|
|
44
35
|
if ((_a = req.cookies) === null || _a === void 0 ? void 0 : _a.jwt) {
|
|
45
36
|
try {
|
|
46
37
|
const payload = jsonwebtoken_1.default.verify(req.cookies.jwt, process.env.JWT_KEY);
|
|
@@ -49,13 +40,13 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
49
40
|
catch (err) { }
|
|
50
41
|
}
|
|
51
42
|
if ((_c = (_b = req.currentAuth) === null || _b === void 0 ? void 0 : _b.missing) === null || _c === void 0 ? void 0 : _c.includes("password")) {
|
|
52
|
-
throw new
|
|
43
|
+
throw new common_1.MissingPasswordError();
|
|
53
44
|
}
|
|
54
45
|
if ((_e = (_d = req.currentAuth) === null || _d === void 0 ? void 0 : _d.missing) === null || _e === void 0 ? void 0 : _e.includes("securityQuestion")) {
|
|
55
|
-
throw new
|
|
46
|
+
throw new common_1.MissingSecurityQuestionError();
|
|
56
47
|
}
|
|
57
48
|
}
|
|
58
|
-
if (authorizationTypes.includes(
|
|
49
|
+
if (authorizationTypes.includes(common_1.AuthorizationType.Admin)) {
|
|
59
50
|
if ((_f = req.cookies) === null || _f === void 0 ? void 0 : _f.adminJwt) {
|
|
60
51
|
try {
|
|
61
52
|
const payload = jsonwebtoken_1.default.verify(req.cookies.adminJwt, process.env.JWT_KEY_ADMIN);
|
|
@@ -64,7 +55,7 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
64
55
|
catch (err) { }
|
|
65
56
|
}
|
|
66
57
|
}
|
|
67
|
-
if (authorizationTypes.includes(
|
|
58
|
+
if (authorizationTypes.includes(common_1.AuthorizationType.Partner) &&
|
|
68
59
|
req.currentAuth) {
|
|
69
60
|
const Partner = yield (0, partner_1.buildPartner)(mongoose);
|
|
70
61
|
const partner = yield Partner.findOne({
|
|
@@ -74,14 +65,14 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
74
65
|
req.partner = partner;
|
|
75
66
|
}
|
|
76
67
|
}
|
|
77
|
-
if (authorizationTypes.includes(
|
|
68
|
+
if (authorizationTypes.includes(common_1.AuthorizationType.UserNoKYC)) {
|
|
78
69
|
let individualUser;
|
|
79
70
|
let businessUser;
|
|
80
71
|
try {
|
|
81
72
|
const User = yield (0, user_1.buildUser)(mongoose);
|
|
82
73
|
individualUser = yield User.findOne({
|
|
83
74
|
authId: req.currentAuth.id,
|
|
84
|
-
attributes: { $ne:
|
|
75
|
+
attributes: { $ne: common_1.UserAttribute.deleted },
|
|
85
76
|
});
|
|
86
77
|
}
|
|
87
78
|
catch (err) {
|
|
@@ -91,7 +82,7 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
91
82
|
const BusinessUser = yield (0, business_user_1.buildBusinessUser)(mongoose);
|
|
92
83
|
businessUser = yield BusinessUser.findOne({
|
|
93
84
|
authId: req.currentAuth.id,
|
|
94
|
-
attributes: { $ne:
|
|
85
|
+
attributes: { $ne: common_1.UserAttribute.deleted },
|
|
95
86
|
});
|
|
96
87
|
}
|
|
97
88
|
catch (err) {
|
|
@@ -102,19 +93,19 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
102
93
|
req.user = user;
|
|
103
94
|
}
|
|
104
95
|
}
|
|
105
|
-
if (authorizationTypes.includes(
|
|
96
|
+
if (authorizationTypes.includes(common_1.AuthorizationType.User)) {
|
|
106
97
|
let individualUser;
|
|
107
98
|
let businessUser;
|
|
108
99
|
try {
|
|
109
100
|
const User = yield (0, user_1.buildUser)(mongoose);
|
|
110
101
|
individualUser = yield User.findOne({
|
|
111
102
|
authId: req.currentAuth.id,
|
|
112
|
-
attributes: { $ne:
|
|
103
|
+
attributes: { $ne: common_1.UserAttribute.deleted },
|
|
113
104
|
});
|
|
114
105
|
if (!individualUser) {
|
|
115
106
|
throw new Error();
|
|
116
107
|
}
|
|
117
|
-
if ((individualUser === null || individualUser === void 0 ? void 0 : individualUser.kycStatus) !==
|
|
108
|
+
if ((individualUser === null || individualUser === void 0 ? void 0 : individualUser.kycStatus) !== common_1.KYCStatus.Passed) {
|
|
118
109
|
missingKYC = true;
|
|
119
110
|
throw new Error();
|
|
120
111
|
}
|
|
@@ -130,7 +121,7 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
130
121
|
if (!businessUser) {
|
|
131
122
|
throw new Error();
|
|
132
123
|
}
|
|
133
|
-
if ((businessUser === null || businessUser === void 0 ? void 0 : businessUser.kycStatus) !==
|
|
124
|
+
if ((businessUser === null || businessUser === void 0 ? void 0 : businessUser.kycStatus) !== common_1.KYCStatus.businessApproved) {
|
|
134
125
|
missingKYC = true;
|
|
135
126
|
throw new Error();
|
|
136
127
|
}
|
|
@@ -143,18 +134,18 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
143
134
|
req.user = user;
|
|
144
135
|
}
|
|
145
136
|
}
|
|
146
|
-
if (authorizationTypes.includes(
|
|
137
|
+
if (authorizationTypes.includes(common_1.AuthorizationType.Broker)) {
|
|
147
138
|
let brokerBusinessUser;
|
|
148
139
|
try {
|
|
149
140
|
const BusinessUser = yield (0, business_user_1.buildBusinessUser)(mongoose);
|
|
150
141
|
brokerBusinessUser = yield BusinessUser.findOne({
|
|
151
142
|
authId: req.currentAuth.id,
|
|
152
|
-
attributes: { $e:
|
|
143
|
+
attributes: { $e: common_1.UserAttribute.broker },
|
|
153
144
|
});
|
|
154
145
|
if (!brokerBusinessUser) {
|
|
155
146
|
throw new Error();
|
|
156
147
|
}
|
|
157
|
-
if ((brokerBusinessUser === null || brokerBusinessUser === void 0 ? void 0 : brokerBusinessUser.kycStatus) !==
|
|
148
|
+
if ((brokerBusinessUser === null || brokerBusinessUser === void 0 ? void 0 : brokerBusinessUser.kycStatus) !== common_1.KYCStatus.businessApproved) {
|
|
158
149
|
missingKYC = true;
|
|
159
150
|
throw new Error();
|
|
160
151
|
}
|
|
@@ -175,30 +166,30 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
175
166
|
!req.partner &&
|
|
176
167
|
!req.validAdminApiKey) ||
|
|
177
168
|
(!req.currentAuth &&
|
|
178
|
-
!authorizationTypes.includes(
|
|
169
|
+
!authorizationTypes.includes(common_1.AuthorizationType.Auth) &&
|
|
179
170
|
!req.user)) {
|
|
180
171
|
if (req.currentAdminAuth &&
|
|
181
|
-
authorizationTypes.includes(
|
|
172
|
+
authorizationTypes.includes(common_1.AuthorizationType.Admin)) {
|
|
182
173
|
next();
|
|
183
174
|
return;
|
|
184
175
|
}
|
|
185
176
|
if (missingKYC) {
|
|
186
|
-
throw new
|
|
177
|
+
throw new common_1.MissingKYCApprovalError();
|
|
187
178
|
}
|
|
188
|
-
if ((authorizationTypes.includes(
|
|
189
|
-
authorizationTypes.includes(
|
|
179
|
+
if ((authorizationTypes.includes(common_1.AuthorizationType.User) ||
|
|
180
|
+
authorizationTypes.includes(common_1.AuthorizationType.UserNoKYC)) &&
|
|
190
181
|
((_g = req.cookies) === null || _g === void 0 ? void 0 : _g.jwt)) {
|
|
191
|
-
throw new
|
|
182
|
+
throw new common_1.MissingUserError();
|
|
192
183
|
}
|
|
193
|
-
if (authorizationTypes.includes(
|
|
184
|
+
if (authorizationTypes.includes(common_1.AuthorizationType.Admin) &&
|
|
194
185
|
authorizationTypes.length === 1 &&
|
|
195
186
|
((_h = req.cookies) === null || _h === void 0 ? void 0 : _h.jwt)) {
|
|
196
|
-
throw new
|
|
187
|
+
throw new common_1.AdminOnlyError();
|
|
197
188
|
}
|
|
198
|
-
if (!req.user && authorizationTypes.includes(
|
|
199
|
-
throw new
|
|
189
|
+
if (!req.user && authorizationTypes.includes(common_1.AuthorizationType.Broker)) {
|
|
190
|
+
throw new common_1.NotBrokerError();
|
|
200
191
|
}
|
|
201
|
-
throw new
|
|
192
|
+
throw new common_1.NotAuthorizedError();
|
|
202
193
|
}
|
|
203
194
|
next();
|
|
204
195
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.errorHandler = void 0;
|
|
4
|
-
const
|
|
4
|
+
const common_1 = require("@riocrypto/common");
|
|
5
5
|
const errorHandler = (err, req, res, next) => {
|
|
6
|
-
if (err instanceof
|
|
6
|
+
if (err instanceof common_1.CustomError) {
|
|
7
7
|
return res.status(err.statusCode).send({ errors: err.serializeErrors() });
|
|
8
8
|
}
|
|
9
9
|
console.error(err);
|
|
@@ -10,10 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.getOrder = void 0;
|
|
13
|
-
const not_authorized_error_1 = require("../errors/not-authorized-error");
|
|
14
|
-
const wrong_processor_error_1 = require("../errors/wrong-processor-error");
|
|
15
13
|
const order_1 = require("../models/order");
|
|
16
|
-
const
|
|
14
|
+
const common_1 = require("@riocrypto/common");
|
|
17
15
|
const getOrder = (req, res, next, mongoose, onlyBankOrders) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
16
|
var _a;
|
|
19
17
|
let orderId = "";
|
|
@@ -34,22 +32,22 @@ const getOrder = (req, res, next, mongoose, onlyBankOrders) => __awaiter(void 0,
|
|
|
34
32
|
}
|
|
35
33
|
if (onlyBankOrders) {
|
|
36
34
|
if ([
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
common_1.Processor.Interbank,
|
|
36
|
+
common_1.Processor.SPEI,
|
|
37
|
+
common_1.Processor.SWIFT,
|
|
38
|
+
common_1.Processor.SPID,
|
|
41
39
|
].includes(order.processor)) {
|
|
42
40
|
req.order = order;
|
|
43
41
|
}
|
|
44
42
|
else {
|
|
45
|
-
throw new
|
|
43
|
+
throw new common_1.WrongProcessorError();
|
|
46
44
|
}
|
|
47
45
|
}
|
|
48
46
|
else {
|
|
49
47
|
req.order = order;
|
|
50
48
|
}
|
|
51
49
|
if (req.order.userId !== ((_a = req.user) === null || _a === void 0 ? void 0 : _a.toJSON().id) && !req.currentAdminAuth) {
|
|
52
|
-
throw new
|
|
50
|
+
throw new common_1.NotAuthorizedError();
|
|
53
51
|
}
|
|
54
52
|
}
|
|
55
53
|
next();
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.getUser = void 0;
|
|
13
13
|
const business_user_1 = require("../models/business-user");
|
|
14
14
|
const user_1 = require("../models/user");
|
|
15
|
-
const
|
|
15
|
+
const common_1 = require("@riocrypto/common");
|
|
16
16
|
const getUser = (req, res, next, mongoose) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
let individualUser;
|
|
18
18
|
let businessUser;
|
|
@@ -20,7 +20,7 @@ const getUser = (req, res, next, mongoose) => __awaiter(void 0, void 0, void 0,
|
|
|
20
20
|
const User = yield (0, user_1.buildUser)(mongoose);
|
|
21
21
|
individualUser = yield User.findOne({
|
|
22
22
|
phoneNumber: req.currentAuth.phoneNumber,
|
|
23
|
-
attributes: { $ne:
|
|
23
|
+
attributes: { $ne: common_1.UserAttribute.deleted },
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
catch (err) {
|
|
@@ -30,7 +30,7 @@ const getUser = (req, res, next, mongoose) => __awaiter(void 0, void 0, void 0,
|
|
|
30
30
|
const BusinessUser = yield (0, business_user_1.buildBusinessUser)(mongoose);
|
|
31
31
|
businessUser = yield BusinessUser.findOne({
|
|
32
32
|
phoneNumber: req.currentAuth.phoneNumber,
|
|
33
|
-
attributes: { $ne:
|
|
33
|
+
attributes: { $ne: common_1.UserAttribute.deleted },
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
catch (err) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.requireAdminApiKey = void 0;
|
|
4
|
-
const
|
|
4
|
+
const common_1 = require("@riocrypto/common");
|
|
5
5
|
const requireAdminApiKey = (req, res, next) => {
|
|
6
6
|
if (!req.validAdminApiKey) {
|
|
7
|
-
throw new
|
|
7
|
+
throw new common_1.NotAuthorizedError();
|
|
8
8
|
}
|
|
9
9
|
next();
|
|
10
10
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.requireAuth = void 0;
|
|
4
|
-
const
|
|
4
|
+
const common_1 = require("@riocrypto/common");
|
|
5
5
|
const requireAuth = (req, res, next) => {
|
|
6
6
|
if (!req.currentAuth) {
|
|
7
|
-
throw new
|
|
7
|
+
throw new common_1.NotAuthorizedError();
|
|
8
8
|
}
|
|
9
9
|
next();
|
|
10
10
|
};
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.requirePriveleges = void 0;
|
|
4
|
-
const
|
|
5
|
-
const not_authorized_error_1 = require("../errors/not-authorized-error");
|
|
4
|
+
const common_1 = require("@riocrypto/common");
|
|
6
5
|
const requirePriveleges = (req, res, next) => {
|
|
7
6
|
if (req.currentAuth && !req.user) {
|
|
8
|
-
throw new
|
|
7
|
+
throw new common_1.MissingUserError();
|
|
9
8
|
}
|
|
10
9
|
if (!req.partnerId && !req.user && !req.currentAdminAuth) {
|
|
11
|
-
throw new
|
|
10
|
+
throw new common_1.NotAuthorizedError();
|
|
12
11
|
}
|
|
13
12
|
next();
|
|
14
13
|
};
|
|
@@ -10,19 +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.validateAuth = void 0;
|
|
13
|
-
const
|
|
14
|
-
const missing_security_question_error_1 = require("../errors/missing-security-question-error");
|
|
13
|
+
const common_1 = require("@riocrypto/common");
|
|
15
14
|
const validateAuth = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
15
|
const auth = req.currentAuth;
|
|
17
16
|
if (auth) {
|
|
18
17
|
if (auth.missing.includes("password")) {
|
|
19
|
-
throw new
|
|
18
|
+
throw new common_1.MissingPasswordError();
|
|
20
19
|
}
|
|
21
20
|
if (auth.missing.includes("securityQuestion")) {
|
|
22
|
-
throw new
|
|
21
|
+
throw new common_1.MissingSecurityQuestionError();
|
|
23
22
|
}
|
|
24
23
|
if (auth.missing.includes("securityAnswer")) {
|
|
25
|
-
throw new
|
|
24
|
+
throw new common_1.MissingSecurityQuestionError();
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
27
|
next();
|