@riocrypto/common 1.0.504 → 1.0.506
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/index.d.ts +0 -41
- package/build/index.js +0 -41
- package/package.json +2 -2
- package/build/clients/bitstamp-client.d.ts +0 -16
- package/build/clients/bitstamp-client.js +0 -83
- package/build/clients/ccxt-client.d.ts +0 -48
- package/build/clients/ccxt-client.js +0 -201
- package/build/clients/etherscan-client.d.ts +0 -6
- package/build/clients/etherscan-client.js +0 -24
- package/build/clients/fireblocks-client.d.ts +0 -15
- package/build/clients/fireblocks-client.js +0 -140
- package/build/clients/fixer-client.d.ts +0 -8
- package/build/clients/fixer-client.js +0 -34
- package/build/clients/gueno-client.d.ts +0 -10
- package/build/clients/gueno-client.js +0 -44
- package/build/clients/kapstar-client.d.ts +0 -6
- package/build/clients/kapstar-client.js +0 -26
- package/build/clients/kushki-client.d.ts +0 -14
- package/build/clients/kushki-client.js +0 -150
- package/build/clients/rio-client.d.ts +0 -82
- package/build/clients/rio-client.js +0 -315
- package/build/clients/slack-client.d.ts +0 -7
- package/build/clients/slack-client.js +0 -34
- package/build/helpers/get-user-from-client-helper.d.ts +0 -4
- package/build/helpers/get-user-from-client-helper.js +0 -41
- package/build/helpers/get-user-helper.d.ts +0 -4
- package/build/helpers/get-user-helper.js +0 -35
- package/build/middlewares/authorize.d.ts +0 -28
- package/build/middlewares/authorize.js +0 -195
- package/build/middlewares/current-admin-auth.d.ts +0 -15
- package/build/middlewares/current-admin-auth.js +0 -20
- package/build/middlewares/current-auth.d.ts +0 -16
- package/build/middlewares/current-auth.js +0 -20
- package/build/middlewares/error-handler.d.ts +0 -2
- package/build/middlewares/error-handler.js +0 -14
- package/build/middlewares/get-order.d.ts +0 -11
- package/build/middlewares/get-order.js +0 -57
- package/build/middlewares/get-partner.d.ts +0 -10
- package/build/middlewares/get-partner.js +0 -41
- package/build/middlewares/get-user.d.ts +0 -12
- package/build/middlewares/get-user.js +0 -45
- package/build/middlewares/require-admin-api-key.d.ts +0 -2
- package/build/middlewares/require-admin-api-key.js +0 -11
- package/build/middlewares/require-auth.d.ts +0 -2
- package/build/middlewares/require-auth.js +0 -11
- package/build/middlewares/require-priveleges.d.ts +0 -2
- package/build/middlewares/require-priveleges.js +0 -15
- package/build/middlewares/validate-auth.d.ts +0 -2
- package/build/middlewares/validate-auth.js +0 -30
- package/build/middlewares/validate-kyc.d.ts +0 -2
- package/build/middlewares/validate-kyc.js +0 -30
- package/build/middlewares/validate-order.d.ts +0 -0
- package/build/middlewares/validate-order.js +0 -20
- package/build/middlewares/validate-request.d.ts +0 -2
- package/build/middlewares/validate-request.js +0 -13
- package/build/middlewares/verify-admin-api-key.d.ts +0 -9
- package/build/middlewares/verify-admin-api-key.js +0 -11
- package/build/models/admin-auth.d.ts +0 -16
- package/build/models/admin-auth.js +0 -59
- package/build/models/auth.d.ts +0 -24
- package/build/models/auth.js +0 -83
- package/build/models/bank-payout.d.ts +0 -20
- package/build/models/bank-payout.js +0 -44
- package/build/models/business-user.d.ts +0 -57
- package/build/models/business-user.js +0 -111
- package/build/models/ccxt-order.d.ts +0 -16
- package/build/models/ccxt-order.js +0 -37
- package/build/models/checked-address.d.ts +0 -17
- package/build/models/checked-address.js +0 -37
- package/build/models/kushki-payment.d.ts +0 -16
- package/build/models/kushki-payment.js +0 -37
- package/build/models/kyc.d.ts +0 -20
- package/build/models/kyc.js +0 -45
- package/build/models/order.d.ts +0 -67
- package/build/models/order.js +0 -123
- package/build/models/partner.d.ts +0 -35
- package/build/models/partner.js +0 -69
- package/build/models/rio-settings.d.ts +0 -12
- package/build/models/rio-settings.js +0 -29
- package/build/models/user.d.ts +0 -53
- package/build/models/user.js +0 -94
- package/build/services/apiKey.d.ts +0 -3
- package/build/services/apiKey.js +0 -24
- package/build/services/password.d.ts +0 -4
- package/build/services/password.js +0 -32
- package/build/services/s3.d.ts +0 -5
- package/build/services/s3.js +0 -21
- package/build/types.d.ts +0 -93
- package/build/types.js +0 -109
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.RioClient = void 0;
|
|
13
|
-
class RioClient {
|
|
14
|
-
constructor(axios) {
|
|
15
|
-
this.axios = axios;
|
|
16
|
-
}
|
|
17
|
-
getOrders() {
|
|
18
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
const { data } = yield this.axios.get(`/api/orders`);
|
|
20
|
-
return data;
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
getUsers() {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
const { data } = yield this.axios.get(`/api/users`);
|
|
26
|
-
return data;
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
getBusinessUsers() {
|
|
30
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
const { data } = yield this.axios.get(`/api/business/users`);
|
|
32
|
-
return data;
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
signin(email, password) {
|
|
36
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
const { data } = yield this.axios.post(`/api/admin/signin`, {
|
|
38
|
-
email,
|
|
39
|
-
password,
|
|
40
|
-
});
|
|
41
|
-
return data;
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
updateUser(update, userId) {
|
|
45
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
const { data } = yield this.axios.patch(`/api/users/${userId}`, update);
|
|
47
|
-
return data;
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
updateBusinessUser(update, businessUserId) {
|
|
51
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
const { data } = yield this.axios.patch(`/api/business/users/${businessUserId}`, update);
|
|
53
|
-
return data;
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
updateAdminUserPassword({ password, newPassword, }) {
|
|
57
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
const { data } = yield this.axios.patch(`/api/admin`, {
|
|
59
|
-
password,
|
|
60
|
-
newPassword,
|
|
61
|
-
});
|
|
62
|
-
return data;
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
getAdminUser() {
|
|
66
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
const { data } = yield this.axios.get(`/api/admin`);
|
|
68
|
-
return data;
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
signoutAdmin() {
|
|
72
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
-
yield this.axios.post("/api/admin/signout", {});
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
getRioSettings() {
|
|
77
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
const { data } = yield this.axios.get(`/api/settings`);
|
|
79
|
-
return data;
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
createRioSettings(rioSettings) {
|
|
83
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
yield this.axios.post(`/api/settings`, rioSettings);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
updateRioSettings(update) {
|
|
88
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
const { data } = yield this.axios.patch(`/api/settings`, update);
|
|
90
|
-
return data;
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
confirmBankPayment(orderId) {
|
|
94
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
const { data } = yield this.axios.post(`/api/payments/bank/confirm`, {
|
|
96
|
-
orderId,
|
|
97
|
-
});
|
|
98
|
-
return data;
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
getUser() {
|
|
102
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
const { data } = yield this.axios.get("/api/users/current");
|
|
104
|
-
return data;
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
getBusinessUser() {
|
|
108
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
-
const { data } = yield this.axios.get("/api/business/users/current");
|
|
110
|
-
return data;
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
createUser(user) {
|
|
114
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
-
yield this.axios.post("/api/users/current-auth", user);
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
createBusinessUser(businessUser) {
|
|
119
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
-
const response = yield this.axios.post("/api/business/users/current-auth", businessUser);
|
|
121
|
-
return response.data;
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
createBrokerCustomer(businessUser) {
|
|
125
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
const response = yield this.axios.post("/api/business/users/broker-customers/current-auth", businessUser);
|
|
127
|
-
return response.data;
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
sendPhoneAuthCode(phoneNumber) {
|
|
131
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
-
yield this.axios.post("/api/auth/sendCode", {
|
|
133
|
-
phoneNumber,
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
authExists(phoneNumber) {
|
|
138
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
-
const response = yield this.axios.post("/api/auth/exists", {
|
|
140
|
-
phoneNumber,
|
|
141
|
-
});
|
|
142
|
-
return response.data.exists;
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
uploadCOI(businessUserId, formData) {
|
|
146
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
-
const { data } = yield this.axios.patch(`/api/business/users/${businessUserId}/coi`, formData);
|
|
148
|
-
return data;
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
uploadKYCReport(businessUserId, formData) {
|
|
152
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
-
const { data } = yield this.axios.patch(`/api/business/users/${businessUserId}/kyc-report`, formData);
|
|
154
|
-
return data;
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
getSecurityQuestion() {
|
|
158
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
-
const response = yield this.axios.get("/api/auth/security-question", {});
|
|
160
|
-
return response.data.question;
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
signout() {
|
|
164
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
165
|
-
yield this.axios.post("/api/auth/signout", {});
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
verifyPhoneCode(phoneNumber, code) {
|
|
169
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
170
|
-
yield this.axios.post("/api/auth/verifycode", {
|
|
171
|
-
phoneNumber,
|
|
172
|
-
code,
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
createAuth(password) {
|
|
177
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
-
yield this.axios.post("/api/auth", {
|
|
179
|
-
password,
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
createOrder(order) {
|
|
184
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
-
const response = yield this.axios.post("/api/orders", order);
|
|
186
|
-
return response.data;
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
getOrder(id) {
|
|
190
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
191
|
-
const response = yield this.axios.get(`/api/orders/${id}`);
|
|
192
|
-
return response.data;
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
initBankPayout(oid, accountNumber) {
|
|
196
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
197
|
-
const response = yield this.axios.post(`/api/payouts/bank`, {
|
|
198
|
-
orderId: oid,
|
|
199
|
-
accountNumber,
|
|
200
|
-
});
|
|
201
|
-
return response.data;
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
getBankPayout(orderId) {
|
|
205
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
206
|
-
const response = yield this.axios.get(`/api/payouts/bank?orderId=${orderId}`);
|
|
207
|
-
return response.data;
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
checkAddress(address, crypto) {
|
|
211
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
212
|
-
const response = yield this.axios.post(`/api/kyt/address`, {
|
|
213
|
-
address,
|
|
214
|
-
crypto,
|
|
215
|
-
});
|
|
216
|
-
return response.data;
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
getSupportedPaymentMethods(fiat, country) {
|
|
220
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
221
|
-
const response = yield this.axios.get(`/api/payment-methods/supported?fiat=${fiat}&country=${country}`);
|
|
222
|
-
return response.data;
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
getBrokerCustomers() {
|
|
226
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
227
|
-
const response = yield this.axios.get(`/api/business/users/broker-customers`);
|
|
228
|
-
return response.data;
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
getSupportedPayoutMethods(fiat, country) {
|
|
232
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
233
|
-
const response = yield this.axios.get(`/api/payout-methods/supported?fiat=${fiat}&country=${country}`);
|
|
234
|
-
return response.data;
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
getPartnerLayout(partnerId) {
|
|
238
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
239
|
-
const { data } = yield this.axios.get(`/api/partners/${partnerId}/layout`);
|
|
240
|
-
return data;
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
createClipCardPayment(orderId) {
|
|
244
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
245
|
-
const { data } = yield this.axios.post(`/api/payments/card/clip`, {
|
|
246
|
-
orderId,
|
|
247
|
-
});
|
|
248
|
-
return data;
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
createConektaPayment(orderId) {
|
|
252
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
253
|
-
const { data } = yield this.axios.post(`/api/payments/card/conekta`, {
|
|
254
|
-
orderId,
|
|
255
|
-
});
|
|
256
|
-
return data;
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
createKushkiPayment(orderId, token) {
|
|
260
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
261
|
-
const { data } = yield this.axios.post(`/api/payments/card/kushki`, {
|
|
262
|
-
orderId,
|
|
263
|
-
token,
|
|
264
|
-
});
|
|
265
|
-
return data;
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
createKushkiBankPayment(orderId) {
|
|
269
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
270
|
-
const { data } = yield this.axios.post(`/api/payments/bank/kushki`, {
|
|
271
|
-
orderId,
|
|
272
|
-
});
|
|
273
|
-
return data;
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
createSPEIPayment(orderId) {
|
|
277
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
278
|
-
const { data } = yield this.axios.post(`/api/payments/bank/spei`, {
|
|
279
|
-
orderId,
|
|
280
|
-
});
|
|
281
|
-
return data;
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
createSPIDPayment(orderId) {
|
|
285
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
286
|
-
const { data } = yield this.axios.post(`/api/payments/bank/spid`, {
|
|
287
|
-
orderId,
|
|
288
|
-
});
|
|
289
|
-
return data;
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
createSWIFTPayment(orderId) {
|
|
293
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
294
|
-
const { data } = yield this.axios.post(`/api/payments/bank/swift`, {
|
|
295
|
-
orderId,
|
|
296
|
-
});
|
|
297
|
-
return data;
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
createInterbankPayment(orderId) {
|
|
301
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
302
|
-
const { data } = yield this.axios.post(`/api/payments/bank/interbank`, {
|
|
303
|
-
orderId,
|
|
304
|
-
});
|
|
305
|
-
return data;
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
updateAuth(update, id) {
|
|
309
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
310
|
-
const { data } = yield this.axios.patch(`/api/auth/${id}`, update);
|
|
311
|
-
return data;
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
exports.RioClient = RioClient;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.slackClient = void 0;
|
|
16
|
-
const axios_1 = __importDefault(require("axios"));
|
|
17
|
-
class SlackClient {
|
|
18
|
-
constructor(webhookUrl) {
|
|
19
|
-
this.webhookUrl = webhookUrl;
|
|
20
|
-
}
|
|
21
|
-
sendMessage(message) {
|
|
22
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
try {
|
|
24
|
-
yield axios_1.default.post(this.webhookUrl, {
|
|
25
|
-
text: message,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
console.log(error);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.slackClient = new SlackClient(process.env.SLACK_WEBHOOK_URL);
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { AxiosInstance } from "axios";
|
|
2
|
-
import { BusinessUser } from "../types/business-user";
|
|
3
|
-
import { User } from "../types/user";
|
|
4
|
-
export declare const getUserFromClientHelper: (client: AxiosInstance, includeDeleted?: boolean) => Promise<User | BusinessUser | null | undefined>;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getUserFromClientHelper = void 0;
|
|
13
|
-
const rio_client_1 = require("../clients/rio-client");
|
|
14
|
-
const user_attribute_1 = require("../types/user-attribute");
|
|
15
|
-
const getUserFromClientHelper = (client, includeDeleted) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
-
var _a;
|
|
17
|
-
let individualUser;
|
|
18
|
-
let businessUser;
|
|
19
|
-
try {
|
|
20
|
-
individualUser = yield new rio_client_1.RioClient(client).getUser();
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
individualUser = null;
|
|
24
|
-
}
|
|
25
|
-
try {
|
|
26
|
-
businessUser = yield new rio_client_1.RioClient(client).getBusinessUser();
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
businessUser = null;
|
|
30
|
-
}
|
|
31
|
-
const user = individualUser || businessUser;
|
|
32
|
-
if (includeDeleted) {
|
|
33
|
-
return user;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
if ((_a = user === null || user === void 0 ? void 0 : user.attributes) === null || _a === void 0 ? void 0 : _a.includes(user_attribute_1.UserAttribute.deleted)) {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
exports.getUserFromClientHelper = getUserFromClientHelper;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Mongoose } from "mongoose";
|
|
2
|
-
import { User as UserType } from "../types/user";
|
|
3
|
-
import { BusinessUser as BusinessUserType } from "../types/business-user";
|
|
4
|
-
export declare const getUserHelper: (id: string, mongoose: Mongoose) => Promise<UserType | BusinessUserType | null>;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getUserHelper = void 0;
|
|
13
|
-
const business_user_1 = require("../models/business-user");
|
|
14
|
-
const user_1 = require("../models/user");
|
|
15
|
-
const getUserHelper = (id, mongoose) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
-
let individualUser;
|
|
17
|
-
let businessUser;
|
|
18
|
-
const User = (0, user_1.buildUser)(mongoose);
|
|
19
|
-
const BusinessUser = (0, business_user_1.buildBusinessUser)(mongoose);
|
|
20
|
-
try {
|
|
21
|
-
individualUser = yield User.findById(id);
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
individualUser = null;
|
|
25
|
-
}
|
|
26
|
-
try {
|
|
27
|
-
businessUser = yield BusinessUser.findById(id);
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
businessUser = null;
|
|
31
|
-
}
|
|
32
|
-
const user = individualUser || businessUser;
|
|
33
|
-
return user;
|
|
34
|
-
});
|
|
35
|
-
exports.getUserHelper = getUserHelper;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Request, Response, NextFunction } from "express";
|
|
2
|
-
import { BusinessUserDoc } from "../models/business-user";
|
|
3
|
-
import { UserDoc } from "../models/user";
|
|
4
|
-
import { Mongoose } from "mongoose";
|
|
5
|
-
import { AuthorizationType } from "../types/authorization-type";
|
|
6
|
-
import { PartnerDoc } from "../models/partner";
|
|
7
|
-
interface AuthPayload {
|
|
8
|
-
id: string;
|
|
9
|
-
phoneNumber: string;
|
|
10
|
-
missing: string[];
|
|
11
|
-
}
|
|
12
|
-
interface AdminAuthPayload {
|
|
13
|
-
id: string;
|
|
14
|
-
email: string;
|
|
15
|
-
}
|
|
16
|
-
declare global {
|
|
17
|
-
namespace Express {
|
|
18
|
-
interface Request {
|
|
19
|
-
currentAuth?: AuthPayload;
|
|
20
|
-
currentAdminAuth?: AdminAuthPayload;
|
|
21
|
-
user?: UserDoc | BusinessUserDoc;
|
|
22
|
-
partner?: PartnerDoc;
|
|
23
|
-
session?: any;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
export declare const authorize: (req: Request, res: Response, next: NextFunction, mongoose: Mongoose, authorizationTypes: AuthorizationType[]) => Promise<void>;
|
|
28
|
-
export {};
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.authorize = void 0;
|
|
16
|
-
const business_user_1 = require("../models/business-user");
|
|
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
|
-
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
|
-
const partner_1 = require("../models/partner");
|
|
30
|
-
const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
32
|
-
let missingKYC = false;
|
|
33
|
-
if (authorizationTypes.includes(authorization_type_1.AuthorizationType.Auth) ||
|
|
34
|
-
authorizationTypes.includes(authorization_type_1.AuthorizationType.UserNoKYC) ||
|
|
35
|
-
authorizationTypes.includes(authorization_type_1.AuthorizationType.User) ||
|
|
36
|
-
authorizationTypes.includes(authorization_type_1.AuthorizationType.Broker) ||
|
|
37
|
-
authorizationTypes.includes(authorization_type_1.AuthorizationType.Partner)) {
|
|
38
|
-
if ((_a = req.cookies) === null || _a === void 0 ? void 0 : _a.jwt) {
|
|
39
|
-
try {
|
|
40
|
-
const payload = jsonwebtoken_1.default.verify(req.cookies.jwt, process.env.JWT_KEY);
|
|
41
|
-
req.currentAuth = payload;
|
|
42
|
-
}
|
|
43
|
-
catch (err) { }
|
|
44
|
-
}
|
|
45
|
-
if ((_c = (_b = req.currentAuth) === null || _b === void 0 ? void 0 : _b.missing) === null || _c === void 0 ? void 0 : _c.includes("password")) {
|
|
46
|
-
throw new missing_password_error_1.MissingPasswordError();
|
|
47
|
-
}
|
|
48
|
-
if ((_e = (_d = req.currentAuth) === null || _d === void 0 ? void 0 : _d.missing) === null || _e === void 0 ? void 0 : _e.includes("securityQuestion")) {
|
|
49
|
-
throw new missing_security_question_error_1.MissingSecurityQuestionError();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (authorizationTypes.includes(authorization_type_1.AuthorizationType.Admin)) {
|
|
53
|
-
if ((_f = req.cookies) === null || _f === void 0 ? void 0 : _f.adminJwt) {
|
|
54
|
-
try {
|
|
55
|
-
const payload = jsonwebtoken_1.default.verify(req.cookies.adminJwt, process.env.JWT_KEY_ADMIN);
|
|
56
|
-
req.currentAdminAuth = payload;
|
|
57
|
-
}
|
|
58
|
-
catch (err) { }
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
if (authorizationTypes.includes(authorization_type_1.AuthorizationType.Partner) &&
|
|
62
|
-
req.currentAuth) {
|
|
63
|
-
const Partner = yield (0, partner_1.buildPartner)(mongoose);
|
|
64
|
-
const partner = yield Partner.findOne({
|
|
65
|
-
authId: req.currentAuth.id,
|
|
66
|
-
});
|
|
67
|
-
if (partner) {
|
|
68
|
-
req.partner = partner;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if (authorizationTypes.includes(authorization_type_1.AuthorizationType.UserNoKYC)) {
|
|
72
|
-
let individualUser;
|
|
73
|
-
let businessUser;
|
|
74
|
-
try {
|
|
75
|
-
const User = yield (0, user_1.buildUser)(mongoose);
|
|
76
|
-
individualUser = yield User.findOne({
|
|
77
|
-
authId: req.currentAuth.id,
|
|
78
|
-
attributes: { $ne: user_attribute_1.UserAttribute.deleted },
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
catch (err) {
|
|
82
|
-
individualUser = null;
|
|
83
|
-
}
|
|
84
|
-
try {
|
|
85
|
-
const BusinessUser = yield (0, business_user_1.buildBusinessUser)(mongoose);
|
|
86
|
-
businessUser = yield BusinessUser.findOne({
|
|
87
|
-
authId: req.currentAuth.id,
|
|
88
|
-
attributes: { $ne: user_attribute_1.UserAttribute.deleted },
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
catch (err) {
|
|
92
|
-
businessUser = null;
|
|
93
|
-
}
|
|
94
|
-
const user = individualUser || businessUser;
|
|
95
|
-
if (user) {
|
|
96
|
-
req.user = user;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
if (authorizationTypes.includes(authorization_type_1.AuthorizationType.User)) {
|
|
100
|
-
let individualUser;
|
|
101
|
-
let businessUser;
|
|
102
|
-
try {
|
|
103
|
-
const User = yield (0, user_1.buildUser)(mongoose);
|
|
104
|
-
individualUser = yield User.findOne({
|
|
105
|
-
authId: req.currentAuth.id,
|
|
106
|
-
attributes: { $ne: user_attribute_1.UserAttribute.deleted },
|
|
107
|
-
});
|
|
108
|
-
if (!individualUser) {
|
|
109
|
-
throw new Error();
|
|
110
|
-
}
|
|
111
|
-
if ((individualUser === null || individualUser === void 0 ? void 0 : individualUser.kycStatus) !== kyc_status_1.KYCStatus.Passed) {
|
|
112
|
-
missingKYC = true;
|
|
113
|
-
throw new Error();
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
catch (err) {
|
|
117
|
-
individualUser = null;
|
|
118
|
-
}
|
|
119
|
-
try {
|
|
120
|
-
const BusinessUser = yield (0, business_user_1.buildBusinessUser)(mongoose);
|
|
121
|
-
businessUser = yield BusinessUser.findOne({
|
|
122
|
-
authId: req.currentAuth.id,
|
|
123
|
-
});
|
|
124
|
-
if (!businessUser) {
|
|
125
|
-
throw new Error();
|
|
126
|
-
}
|
|
127
|
-
if ((businessUser === null || businessUser === void 0 ? void 0 : businessUser.kycStatus) !== kyc_status_1.KYCStatus.businessApproved) {
|
|
128
|
-
missingKYC = true;
|
|
129
|
-
throw new Error();
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
catch (err) {
|
|
133
|
-
businessUser = null;
|
|
134
|
-
}
|
|
135
|
-
const user = individualUser || businessUser;
|
|
136
|
-
if (user) {
|
|
137
|
-
req.user = user;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
if (authorizationTypes.includes(authorization_type_1.AuthorizationType.Broker)) {
|
|
141
|
-
let brokerBusinessUser;
|
|
142
|
-
try {
|
|
143
|
-
const BusinessUser = yield (0, business_user_1.buildBusinessUser)(mongoose);
|
|
144
|
-
brokerBusinessUser = yield BusinessUser.findOne({
|
|
145
|
-
authId: req.currentAuth.id,
|
|
146
|
-
attributes: { $e: user_attribute_1.UserAttribute.broker },
|
|
147
|
-
});
|
|
148
|
-
if (!brokerBusinessUser) {
|
|
149
|
-
throw new Error();
|
|
150
|
-
}
|
|
151
|
-
if ((brokerBusinessUser === null || brokerBusinessUser === void 0 ? void 0 : brokerBusinessUser.kycStatus) !== kyc_status_1.KYCStatus.businessApproved) {
|
|
152
|
-
missingKYC = true;
|
|
153
|
-
throw new Error();
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
catch (err) {
|
|
157
|
-
brokerBusinessUser = null;
|
|
158
|
-
}
|
|
159
|
-
const user = brokerBusinessUser;
|
|
160
|
-
if (user) {
|
|
161
|
-
req.user = user;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
if (
|
|
165
|
-
// if no auth
|
|
166
|
-
(!req.currentAdminAuth && !req.currentAuth && !req.user && !req.partner) ||
|
|
167
|
-
(!req.currentAuth &&
|
|
168
|
-
!authorizationTypes.includes(authorization_type_1.AuthorizationType.Auth) &&
|
|
169
|
-
!req.user)) {
|
|
170
|
-
if (req.currentAdminAuth &&
|
|
171
|
-
authorizationTypes.includes(authorization_type_1.AuthorizationType.Admin)) {
|
|
172
|
-
next();
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
if (missingKYC) {
|
|
176
|
-
throw new missing_kyc_approval_error_1.MissingKYCApprovalError();
|
|
177
|
-
}
|
|
178
|
-
if ((authorizationTypes.includes(authorization_type_1.AuthorizationType.User) ||
|
|
179
|
-
authorizationTypes.includes(authorization_type_1.AuthorizationType.UserNoKYC)) &&
|
|
180
|
-
((_g = req.cookies) === null || _g === void 0 ? void 0 : _g.jwt)) {
|
|
181
|
-
throw new missing_user_error_1.MissingUserError();
|
|
182
|
-
}
|
|
183
|
-
if (authorizationTypes.includes(authorization_type_1.AuthorizationType.Admin) &&
|
|
184
|
-
authorizationTypes.length === 1 &&
|
|
185
|
-
((_h = req.cookies) === null || _h === void 0 ? void 0 : _h.jwt)) {
|
|
186
|
-
throw new admin_only_error_1.AdminOnlyError();
|
|
187
|
-
}
|
|
188
|
-
if (!req.user && authorizationTypes.includes(authorization_type_1.AuthorizationType.Broker)) {
|
|
189
|
-
throw new not_broker_error_1.NotBrokerError();
|
|
190
|
-
}
|
|
191
|
-
throw new not_authorized_error_1.NotAuthorizedError();
|
|
192
|
-
}
|
|
193
|
-
next();
|
|
194
|
-
});
|
|
195
|
-
exports.authorize = authorize;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Request, Response, NextFunction } from "express";
|
|
2
|
-
interface AuthPayload {
|
|
3
|
-
id: string;
|
|
4
|
-
email: string;
|
|
5
|
-
}
|
|
6
|
-
declare global {
|
|
7
|
-
namespace Express {
|
|
8
|
-
interface Request {
|
|
9
|
-
currentAdminAuth?: AuthPayload;
|
|
10
|
-
session?: any;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
export declare const currentAdminAuth: (req: Request, res: Response, next: NextFunction) => void;
|
|
15
|
-
export {};
|