@riocrypto/common 1.0.506 → 1.0.509

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,82 @@
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 { 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
+ export declare class RioClient {
24
+ private axios;
25
+ constructor(axios: AxiosStatic | AxiosInstance);
26
+ getOrders(): Promise<Order[]>;
27
+ getUsers(): Promise<User[]>;
28
+ getBusinessUsers(): Promise<BusinessUser[]>;
29
+ signin(email: string, password: string): Promise<any>;
30
+ updateUser(update: UserUpdate, userId?: string): Promise<User>;
31
+ updateBusinessUser(update: BusinessUserUpdate, businessUserId?: string): Promise<BusinessUser>;
32
+ updateAdminUserPassword({ password, newPassword, }: {
33
+ password: string;
34
+ newPassword: string;
35
+ }): Promise<Admin>;
36
+ getAdminUser(): Promise<any>;
37
+ signoutAdmin(): Promise<void>;
38
+ getRioSettings(): Promise<RioSettings>;
39
+ createRioSettings(rioSettings: {
40
+ platformFee: number;
41
+ }): Promise<void>;
42
+ updateRioSettings(update: RioSettingsUpdate): Promise<void>;
43
+ confirmBankPayment(orderId: string): Promise<any>;
44
+ getUser(): Promise<User>;
45
+ getBusinessUser(): Promise<BusinessUser>;
46
+ createUser(user: UserInput): Promise<void>;
47
+ createBusinessUser(businessUser: BusinessUserInput): Promise<BusinessUser>;
48
+ createBrokerCustomer(businessUser: BusinessUserInput): Promise<BusinessUser>;
49
+ sendPhoneAuthCode(phoneNumber: string): Promise<void>;
50
+ authExists(phoneNumber: string): Promise<boolean>;
51
+ uploadCOI(businessUserId: string, formData: FormData): Promise<BusinessUser>;
52
+ uploadKYCReport(businessUserId: string, formData: FormData): Promise<BusinessUser>;
53
+ getSecurityQuestion(): Promise<SecurityQuestion>;
54
+ signout(): Promise<void>;
55
+ verifyPhoneCode(phoneNumber: string, code: string): Promise<void>;
56
+ createAuth(password: string): Promise<void>;
57
+ createOrder(order: OrderInput): Promise<Order>;
58
+ getOrder(id: string): Promise<Order>;
59
+ initBankPayout(oid: string, accountNumber: string): Promise<BankPayout>;
60
+ getBankPayout(orderId: string): Promise<BankPayout>;
61
+ checkAddress(address: string, crypto: Crypto): Promise<CheckedAddress>;
62
+ getSupportedPaymentMethods(fiat: Fiat, country: Country): Promise<PaymentMethod[]>;
63
+ getBrokerCustomers(): Promise<BusinessUser[]>;
64
+ getSupportedPayoutMethods(fiat: Fiat, country: Country): Promise<PayoutMethod[]>;
65
+ getPartnerLayout(partnerId: string): Promise<Partner>;
66
+ createClipCardPayment(orderId: string): Promise<{
67
+ paymentId: string;
68
+ paymentRequestUrl: string;
69
+ }>;
70
+ createConektaPayment(orderId: string): Promise<{
71
+ checkoutRequestId: string;
72
+ }>;
73
+ createKushkiPayment(orderId: string, token: string): Promise<{
74
+ paymentId: string;
75
+ }>;
76
+ createKushkiBankPayment(orderId: string): Promise<any>;
77
+ createSPEIPayment(orderId: string): Promise<any>;
78
+ createSPIDPayment(orderId: string): Promise<any>;
79
+ createSWIFTPayment(orderId: string): Promise<any>;
80
+ createInterbankPayment(orderId: string): Promise<any>;
81
+ updateAuth(update: AuthUpdate, id?: string): Promise<Auth>;
82
+ }
@@ -0,0 +1,315 @@
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;
@@ -0,0 +1,4 @@
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>;
@@ -0,0 +1,41 @@
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;
package/build/index.d.ts CHANGED
@@ -140,3 +140,5 @@ export * from "./classes/PaymentMethodAsset";
140
140
  export * from "./classes/PayoutMethodAsset";
141
141
  export * from "./classes/USStateAsset";
142
142
  export * from "./classes/WyrePaymentMethodAsset";
143
+ export * from "./helpers/get-user-from-client-helper";
144
+ export * from "./clients/rio-client";
package/build/index.js CHANGED
@@ -156,3 +156,5 @@ __exportStar(require("./classes/PaymentMethodAsset"), exports);
156
156
  __exportStar(require("./classes/PayoutMethodAsset"), exports);
157
157
  __exportStar(require("./classes/USStateAsset"), exports);
158
158
  __exportStar(require("./classes/WyrePaymentMethodAsset"), exports);
159
+ __exportStar(require("./helpers/get-user-from-client-helper"), exports);
160
+ __exportStar(require("./clients/rio-client"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common",
3
- "version": "1.0.506",
3
+ "version": "1.0.509",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -21,15 +21,10 @@
21
21
  "typescript": "^4.7.4"
22
22
  },
23
23
  "dependencies": {
24
- "@aws-sdk/client-s3": "^3.297.0",
25
24
  "@types/express": "^4.17.13",
26
25
  "axios": "^0.27.2",
27
- "ccxt": "^3.0.30",
28
- "express": "^4.18.1",
29
- "express-validator": "^6.14.2",
30
- "fireblocks-sdk": "^4.0.0",
26
+ "express-validator": "^6.15.0",
31
27
  "jsonwebtoken": "^8.5.1",
32
- "mongoose": "^7.0.2",
33
28
  "node-nats-streaming": "^0.3.2",
34
29
  "uuid": "^9.0.0"
35
30
  }