@riocrypto/common 1.0.646 → 1.0.648

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.
@@ -0,0 +1,94 @@
1
+ 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 { CheckedAddress } from "../types/checked-address";
7
+ import { Country } from "../types/country";
8
+ import { Fiat } from "../types/fiat";
9
+ import { Order } from "../types/order";
10
+ import { OrderInput } from "../types/order-input";
11
+ import { Partner } from "../types/partner";
12
+ import { PaymentMethod } from "../types/payment-method";
13
+ import { PayoutMethod } from "../types/payout-method";
14
+ import { RioSettings } from "../types/rio-settings";
15
+ import { RioSettingsUpdate } from "../types/rio-settings-update";
16
+ import { User } from "../types/user";
17
+ import { UserInput } from "../types/user-input";
18
+ import { UserUpdate } from "../types/user-update";
19
+ import { BankPayment } from "../types/bank-payment";
20
+ import { BankAccount } from "../types/bank-account";
21
+ import { UserType } from "../types/user-type";
22
+ import { Quote } from "../types/quote";
23
+ import { Side } from "../types/side";
24
+ import { Crypto } from "../types/crypto";
25
+ export declare class RioAdminClient {
26
+ private axios;
27
+ constructor(axios: AxiosStatic | AxiosInstance);
28
+ getOrders(): Promise<Order[]>;
29
+ getQuote(crypto: Crypto, fiat: Fiat, quoteInCrypto: boolean, side: Side, amountFiat?: Number, amountCrypto?: Number, country?: Country, paymentMethod?: PaymentMethod, payoutMethod?: PayoutMethod): Promise<Quote>;
30
+ getUsers(type?: UserType, brokerId?: string): Promise<User[]>;
31
+ signinAdmin(email: string, password: string): Promise<any>;
32
+ updateUser(update: UserUpdate, userId?: string): Promise<User>;
33
+ uploadBusinessCOI(id: string, formData: FormData): Promise<User>;
34
+ uploadBusinessKYCReport(id: string, formData: FormData): Promise<User>;
35
+ updateAdmin(update: {
36
+ email?: string;
37
+ password?: string;
38
+ newPassword?: string;
39
+ }): Promise<Admin>;
40
+ getAdminAuth(): Promise<any>;
41
+ signoutAdmin(): Promise<void>;
42
+ getRioSettings(): Promise<RioSettings>;
43
+ createRioSettings(rioSettings: {
44
+ platformFee: number;
45
+ }): Promise<void>;
46
+ updateRioSettings(update: RioSettingsUpdate): Promise<void>;
47
+ confirmBankPayment(orderId: string, amountFiat?: number): Promise<any>;
48
+ confirmBankPayout(orderId: string): Promise<any>;
49
+ getUser(): Promise<User>;
50
+ createUser(user: UserInput): Promise<User>;
51
+ getBankPayment(orderId: string): Promise<BankPayment>;
52
+ verifyBankPayment(orderId: string): Promise<any>;
53
+ sendPhoneAuthCode(phoneNumber: string): Promise<void>;
54
+ getAuth(phoneNumber?: string): Promise<{
55
+ auth: Auth;
56
+ missing: string[];
57
+ }>;
58
+ authHasSecurityQuestion(): Promise<Boolean>;
59
+ signout(): Promise<void>;
60
+ verifyPhoneCode(phoneNumber: string, code: string): Promise<void>;
61
+ signin(password: string): Promise<{
62
+ auth: Auth;
63
+ missing: string[];
64
+ }>;
65
+ refreshToken(): Promise<void>;
66
+ createOrder(order: OrderInput): Promise<Order>;
67
+ cancelOrder(id?: string): Promise<Order>;
68
+ getOrder(id: string): Promise<Order>;
69
+ createBankPayout(oid: string, accountNumber: string, swiftCode?: string): Promise<BankPayout>;
70
+ getBankPayout(orderId: string): Promise<BankPayout>;
71
+ createCheckedAddress(address: string, crypto: Crypto): Promise<CheckedAddress>;
72
+ createBankAccount(country: Country, fiat: Fiat, accountNumber: string, swiftCode?: string, notes?: string): Promise<BankAccount>;
73
+ deleteBankAccount(id: string): Promise<void>;
74
+ getFeesByVolume(): Promise<{
75
+ days: number;
76
+ fee: number;
77
+ volume: number;
78
+ }>;
79
+ getAggregateVolume(): Promise<{
80
+ volume: number;
81
+ revenue: number;
82
+ }>;
83
+ getPaymentMethods(fiat: Fiat, country: Country): Promise<PaymentMethod[]>;
84
+ getBankAccounts(): Promise<BankAccount[]>;
85
+ getSupportedPayoutMethods(fiat: Fiat, country: Country): Promise<PayoutMethod[]>;
86
+ getPartner(partnerId: string): Promise<Partner>;
87
+ createKushkiPayment(orderId: string, token: string): Promise<{
88
+ paymentId: string;
89
+ }>;
90
+ addAuthorizedPhoneNumber(phoneNumber: string): Promise<User>;
91
+ deleteAuthorizedPhoneNumber(phoneNumber: string): Promise<User>;
92
+ createKushkiBankPayment(orderId: string): Promise<any>;
93
+ updateAuth(update: AuthUpdate, id?: string): Promise<Auth>;
94
+ }
@@ -0,0 +1,342 @@
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.RioAdminClient = void 0;
13
+ class RioAdminClient {
14
+ constructor(axios) {
15
+ this.axios = axios;
16
+ axios.interceptors.request.use((config) => {
17
+ // Exclude specific cookie from being sent
18
+ if (config.headers && config.headers.Cookie) {
19
+ config.headers.Cookie = document.cookie.replace("accessToken=; ", "");
20
+ config.headers.Cookie = document.cookie.replace("refreshToken=; ", "");
21
+ }
22
+ return config;
23
+ });
24
+ }
25
+ getOrders() {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ const { data } = yield this.axios.get(`/api/orders`);
28
+ return data;
29
+ });
30
+ }
31
+ getQuote(crypto, fiat, quoteInCrypto, side, amountFiat, amountCrypto, country, paymentMethod, payoutMethod) {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ const { data } = yield this.axios.get(`/api/quotes`, {
34
+ params: {
35
+ crypto,
36
+ fiat,
37
+ amountCrypto,
38
+ amountFiat,
39
+ quoteInCrypto,
40
+ side,
41
+ country,
42
+ paymentMethod,
43
+ payoutMethod,
44
+ },
45
+ });
46
+ return data;
47
+ });
48
+ }
49
+ getUsers(type, brokerId) {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ const { data } = yield this.axios.get(`/api/users`, {
52
+ params: {
53
+ type,
54
+ brokerId,
55
+ },
56
+ });
57
+ return data;
58
+ });
59
+ }
60
+ signinAdmin(email, password) {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ const { data } = yield this.axios.post(`/api/auth/admin/signin`, {
63
+ email,
64
+ password,
65
+ });
66
+ return data;
67
+ });
68
+ }
69
+ updateUser(update, userId) {
70
+ return __awaiter(this, void 0, void 0, function* () {
71
+ const { data } = yield this.axios.patch(`/api/users/${userId || ""}`, update);
72
+ return data;
73
+ });
74
+ }
75
+ uploadBusinessCOI(id, formData) {
76
+ return __awaiter(this, void 0, void 0, function* () {
77
+ const { data } = yield this.axios.post(`/api/users/${id}/coi`, formData);
78
+ return data;
79
+ });
80
+ }
81
+ uploadBusinessKYCReport(id, formData) {
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ const { data } = yield this.axios.post(`/api/users/${id}/kyc-report`, formData);
84
+ return data;
85
+ });
86
+ }
87
+ updateAdmin(update) {
88
+ return __awaiter(this, void 0, void 0, function* () {
89
+ const { data } = yield this.axios.patch(`/api/auth/admin`, update);
90
+ return data;
91
+ });
92
+ }
93
+ getAdminAuth() {
94
+ return __awaiter(this, void 0, void 0, function* () {
95
+ const { data } = yield this.axios.get(`/api/auth/admin`);
96
+ return data;
97
+ });
98
+ }
99
+ signoutAdmin() {
100
+ return __awaiter(this, void 0, void 0, function* () {
101
+ yield this.axios.post("/api/auth/admin/signout", {});
102
+ });
103
+ }
104
+ getRioSettings() {
105
+ return __awaiter(this, void 0, void 0, function* () {
106
+ const { data } = yield this.axios.get(`/api/settings`);
107
+ return data;
108
+ });
109
+ }
110
+ createRioSettings(rioSettings) {
111
+ return __awaiter(this, void 0, void 0, function* () {
112
+ yield this.axios.post(`/api/settings`, rioSettings);
113
+ });
114
+ }
115
+ updateRioSettings(update) {
116
+ return __awaiter(this, void 0, void 0, function* () {
117
+ const { data } = yield this.axios.patch(`/api/settings`, update);
118
+ return data;
119
+ });
120
+ }
121
+ confirmBankPayment(orderId, amountFiat) {
122
+ return __awaiter(this, void 0, void 0, function* () {
123
+ const { data } = yield this.axios.post(`/api/payments/bank/confirm`, {
124
+ orderId,
125
+ amountFiat,
126
+ });
127
+ return data;
128
+ });
129
+ }
130
+ confirmBankPayout(orderId) {
131
+ return __awaiter(this, void 0, void 0, function* () {
132
+ const { data } = yield this.axios.post(`/api/payouts/bank/confirm`, {
133
+ orderId,
134
+ });
135
+ return data;
136
+ });
137
+ }
138
+ getUser() {
139
+ return __awaiter(this, void 0, void 0, function* () {
140
+ const { data } = yield this.axios.get("/api/users");
141
+ return data;
142
+ });
143
+ }
144
+ createUser(user) {
145
+ return __awaiter(this, void 0, void 0, function* () {
146
+ const { data } = yield this.axios.post("/api/users", user);
147
+ return data;
148
+ });
149
+ }
150
+ getBankPayment(orderId) {
151
+ return __awaiter(this, void 0, void 0, function* () {
152
+ const { data } = yield this.axios.get("/api/payments/bank?orderId=" + orderId);
153
+ return data;
154
+ });
155
+ }
156
+ verifyBankPayment(orderId) {
157
+ return __awaiter(this, void 0, void 0, function* () {
158
+ yield this.axios.post("/api/payments/bank/check", {
159
+ orderId,
160
+ });
161
+ });
162
+ }
163
+ sendPhoneAuthCode(phoneNumber) {
164
+ return __awaiter(this, void 0, void 0, function* () {
165
+ yield this.axios.post("/api/auth/phone/send", {
166
+ phoneNumber,
167
+ });
168
+ });
169
+ }
170
+ getAuth(phoneNumber) {
171
+ return __awaiter(this, void 0, void 0, function* () {
172
+ const response = yield this.axios.get(`/api/auth?${phoneNumber ? "phoneNumber=" + phoneNumber : ""}`);
173
+ return response.data;
174
+ });
175
+ }
176
+ authHasSecurityQuestion() {
177
+ return __awaiter(this, void 0, void 0, function* () {
178
+ const response = yield this.axios.get(`/api/auth?checkSecurityQuestion=true`);
179
+ return response.data.hasSecurityQuestion;
180
+ });
181
+ }
182
+ signout() {
183
+ return __awaiter(this, void 0, void 0, function* () {
184
+ yield this.axios.post("/api/auth/signout", {});
185
+ });
186
+ }
187
+ verifyPhoneCode(phoneNumber, code) {
188
+ return __awaiter(this, void 0, void 0, function* () {
189
+ yield this.axios.post("/api/auth/phone/verify", {
190
+ phoneNumber,
191
+ code,
192
+ });
193
+ });
194
+ }
195
+ signin(password) {
196
+ return __awaiter(this, void 0, void 0, function* () {
197
+ const response = yield this.axios.post("/api/auth", {
198
+ password,
199
+ });
200
+ return response.data;
201
+ });
202
+ }
203
+ refreshToken() {
204
+ return __awaiter(this, void 0, void 0, function* () {
205
+ yield this.axios.post("/api/auth/refresh");
206
+ });
207
+ }
208
+ createOrder(order) {
209
+ return __awaiter(this, void 0, void 0, function* () {
210
+ const response = yield this.axios.post("/api/orders", order);
211
+ return response.data;
212
+ });
213
+ }
214
+ cancelOrder(id) {
215
+ return __awaiter(this, void 0, void 0, function* () {
216
+ const response = yield this.axios.post(`/api/orders${id ? `/${id}/cancel` : "/cancel"}`);
217
+ return response.data;
218
+ });
219
+ }
220
+ getOrder(id) {
221
+ return __awaiter(this, void 0, void 0, function* () {
222
+ const response = yield this.axios.get(`/api/orders/${id}`);
223
+ return response.data;
224
+ });
225
+ }
226
+ createBankPayout(oid, accountNumber, swiftCode) {
227
+ return __awaiter(this, void 0, void 0, function* () {
228
+ const response = yield this.axios.post(`/api/payouts/bank`, {
229
+ orderId: oid,
230
+ accountNumber,
231
+ swiftCode,
232
+ });
233
+ return response.data;
234
+ });
235
+ }
236
+ getBankPayout(orderId) {
237
+ return __awaiter(this, void 0, void 0, function* () {
238
+ const response = yield this.axios.get(`/api/payouts/bank?orderId=${orderId}`);
239
+ return response.data;
240
+ });
241
+ }
242
+ createCheckedAddress(address, crypto) {
243
+ return __awaiter(this, void 0, void 0, function* () {
244
+ const response = yield this.axios.post(`/api/kyt/address`, {
245
+ address,
246
+ crypto,
247
+ });
248
+ return response.data;
249
+ });
250
+ }
251
+ createBankAccount(country, fiat, accountNumber, swiftCode, notes) {
252
+ return __awaiter(this, void 0, void 0, function* () {
253
+ const response = yield this.axios.post(`/api/bank/accounts`, {
254
+ country,
255
+ fiat,
256
+ accountNumber,
257
+ swiftCode,
258
+ notes,
259
+ });
260
+ return response.data;
261
+ });
262
+ }
263
+ deleteBankAccount(id) {
264
+ return __awaiter(this, void 0, void 0, function* () {
265
+ yield this.axios.delete(`/api/bank/accounts/${id}`);
266
+ });
267
+ }
268
+ getFeesByVolume() {
269
+ return __awaiter(this, void 0, void 0, function* () {
270
+ const response = yield this.axios.get(`/api/quotes/fees/by-volume`);
271
+ return response.data;
272
+ });
273
+ }
274
+ getAggregateVolume() {
275
+ return __awaiter(this, void 0, void 0, function* () {
276
+ const response = yield this.axios.get(`/api/orders/volume"`);
277
+ return response.data;
278
+ });
279
+ }
280
+ getPaymentMethods(fiat, country) {
281
+ return __awaiter(this, void 0, void 0, function* () {
282
+ const response = yield this.axios.get(`/api/payment-methods?fiat=${fiat}&country=${country}`);
283
+ return response.data;
284
+ });
285
+ }
286
+ getBankAccounts() {
287
+ return __awaiter(this, void 0, void 0, function* () {
288
+ const response = yield this.axios.get(`/api/bank/accounts`);
289
+ return response.data;
290
+ });
291
+ }
292
+ getSupportedPayoutMethods(fiat, country) {
293
+ return __awaiter(this, void 0, void 0, function* () {
294
+ const response = yield this.axios.get(`/api/payout-methods?fiat=${fiat}&country=${country}`);
295
+ return response.data;
296
+ });
297
+ }
298
+ getPartner(partnerId) {
299
+ return __awaiter(this, void 0, void 0, function* () {
300
+ const { data } = yield this.axios.get(`/api/partners/${partnerId}`);
301
+ return data;
302
+ });
303
+ }
304
+ createKushkiPayment(orderId, token) {
305
+ return __awaiter(this, void 0, void 0, function* () {
306
+ const { data } = yield this.axios.post(`/api/payments/card/kushki`, {
307
+ orderId,
308
+ token,
309
+ });
310
+ return data;
311
+ });
312
+ }
313
+ addAuthorizedPhoneNumber(phoneNumber) {
314
+ return __awaiter(this, void 0, void 0, function* () {
315
+ const { data } = yield this.axios.post(`/api/users/authorized-phone-numbers`, {
316
+ phoneNumber,
317
+ });
318
+ return data;
319
+ });
320
+ }
321
+ deleteAuthorizedPhoneNumber(phoneNumber) {
322
+ return __awaiter(this, void 0, void 0, function* () {
323
+ const { data } = yield this.axios.delete(`/api/users/authorized-phone-numbers/${phoneNumber}`);
324
+ return data;
325
+ });
326
+ }
327
+ createKushkiBankPayment(orderId) {
328
+ return __awaiter(this, void 0, void 0, function* () {
329
+ const { data } = yield this.axios.post(`/api/payments/bank/kushki`, {
330
+ orderId,
331
+ });
332
+ return data;
333
+ });
334
+ }
335
+ updateAuth(update, id) {
336
+ return __awaiter(this, void 0, void 0, function* () {
337
+ const { data } = yield this.axios.patch(`/api/auth/${id || ""}`, update);
338
+ return data;
339
+ });
340
+ }
341
+ }
342
+ exports.RioAdminClient = RioAdminClient;
@@ -1,5 +1,4 @@
1
1
  import { AxiosInstance, AxiosStatic } from "axios";
2
- import { Admin } from "../types/admin";
3
2
  import { Auth } from "../types/auth";
4
3
  import { AuthUpdate } from "../types/auth-update";
5
4
  import { BankPayout } from "../types/bank-payout";
@@ -28,17 +27,9 @@ export declare class RioClient {
28
27
  getOrders(): Promise<Order[]>;
29
28
  getQuote(crypto: Crypto, fiat: Fiat, quoteInCrypto: boolean, side: Side, amountFiat?: Number, amountCrypto?: Number, country?: Country, paymentMethod?: PaymentMethod, payoutMethod?: PayoutMethod): Promise<Quote>;
30
29
  getUsers(type?: UserType, brokerId?: string): Promise<User[]>;
31
- signinAdmin(email: string, password: string): Promise<any>;
32
30
  updateUser(update: UserUpdate, userId?: string): Promise<User>;
33
31
  uploadBusinessCOI(id: string, formData: FormData): Promise<User>;
34
32
  uploadBusinessKYCReport(id: string, formData: FormData): Promise<User>;
35
- updateAdmin(update: {
36
- email?: string;
37
- password?: string;
38
- newPassword?: string;
39
- }): Promise<Admin>;
40
- getAdmin(): Promise<any>;
41
- signoutAdmin(): Promise<void>;
42
33
  getRioSettings(): Promise<RioSettings>;
43
34
  createRioSettings(rioSettings: {
44
35
  platformFee: number;
@@ -13,6 +13,13 @@ exports.RioClient = void 0;
13
13
  class RioClient {
14
14
  constructor(axios) {
15
15
  this.axios = axios;
16
+ axios.interceptors.request.use((config) => {
17
+ // Exclude specific cookie from being sent
18
+ if (config.headers && config.headers.Cookie) {
19
+ config.headers.Cookie = document.cookie.replace("adminAccessToken=; ", "");
20
+ }
21
+ return config;
22
+ });
16
23
  }
17
24
  getOrders() {
18
25
  return __awaiter(this, void 0, void 0, function* () {
@@ -49,15 +56,6 @@ class RioClient {
49
56
  return data;
50
57
  });
51
58
  }
52
- signinAdmin(email, password) {
53
- return __awaiter(this, void 0, void 0, function* () {
54
- const { data } = yield this.axios.post(`/api/auth/admin/signin`, {
55
- email,
56
- password,
57
- });
58
- return data;
59
- });
60
- }
61
59
  updateUser(update, userId) {
62
60
  return __awaiter(this, void 0, void 0, function* () {
63
61
  const { data } = yield this.axios.patch(`/api/users/${userId || ""}`, update);
@@ -76,23 +74,6 @@ class RioClient {
76
74
  return data;
77
75
  });
78
76
  }
79
- updateAdmin(update) {
80
- return __awaiter(this, void 0, void 0, function* () {
81
- const { data } = yield this.axios.patch(`/api/auth/admin`, update);
82
- return data;
83
- });
84
- }
85
- getAdmin() {
86
- return __awaiter(this, void 0, void 0, function* () {
87
- const { data } = yield this.axios.get(`/api/auth/admin`);
88
- return data;
89
- });
90
- }
91
- signoutAdmin() {
92
- return __awaiter(this, void 0, void 0, function* () {
93
- yield this.axios.post("/api/auth/admin/signout", {});
94
- });
95
- }
96
77
  getRioSettings() {
97
78
  return __awaiter(this, void 0, void 0, function* () {
98
79
  const { data } = yield this.axios.get(`/api/settings`);
package/build/index.d.ts CHANGED
@@ -137,3 +137,4 @@ export * from "./helpers/get-user-from-client-helper";
137
137
  export * from "./helpers/validate-address";
138
138
  export * from "./helpers/round-down-to-two-decimal-places";
139
139
  export * from "./clients/rio-client";
140
+ export * from "./clients/rio-admin-client";
package/build/index.js CHANGED
@@ -153,3 +153,4 @@ __exportStar(require("./helpers/get-user-from-client-helper"), exports);
153
153
  __exportStar(require("./helpers/validate-address"), exports);
154
154
  __exportStar(require("./helpers/round-down-to-two-decimal-places"), exports);
155
155
  __exportStar(require("./clients/rio-client"), exports);
156
+ __exportStar(require("./clients/rio-admin-client"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common",
3
- "version": "1.0.646",
3
+ "version": "1.0.648",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",