@riocrypto/common-server 1.0.1095 → 1.0.1097

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.
@@ -143,6 +143,7 @@ const getPlatformFees = (mongoose, conversionRateToUSD, amountFiat, fiat, proces
143
143
  platformFeeFiat = amountFiat * netPlatformFee;
144
144
  }
145
145
  if ((fiat === common_1.Fiat.MXN && processor === common_1.Processor.SPEI) ||
146
+ (fiat === common_1.Fiat.MXN && processor === common_1.Processor.Bitso) ||
146
147
  (fiat === common_1.Fiat.USD && processor === common_1.Processor.SPID)) {
147
148
  if (country === common_1.Country.Mexico) {
148
149
  platformFeeFiatTax = platformFeeFiat * 0.16;
package/build/index.d.ts CHANGED
@@ -24,7 +24,7 @@ export * from "./models/user";
24
24
  export * from "./models/ccxt-order";
25
25
  export * from "./models/kushki-payment";
26
26
  export * from "./models/kyc";
27
- export * from "./models/checked-address";
27
+ export * from "./models/crypto-address";
28
28
  export * from "./models/fireblocks-vault";
29
29
  export * from "./models/fireblocks-transfer";
30
30
  export * from "./models/rio-settings";
@@ -51,7 +51,6 @@ export * from "./clients/gueno-client";
51
51
  export * from "./clients/fireblocks-client";
52
52
  export * from "./clients/kapstar-client";
53
53
  export * from "./clients/etherscan-client";
54
- export * from "./clients/rio-client";
55
54
  export * from "./clients/secret-manager-client";
56
55
  export * from "./clients/gcloud-storage-client";
57
56
  export * from "./clients/currency-api-client";
package/build/index.js CHANGED
@@ -40,7 +40,7 @@ __exportStar(require("./models/user"), exports);
40
40
  __exportStar(require("./models/ccxt-order"), exports);
41
41
  __exportStar(require("./models/kushki-payment"), exports);
42
42
  __exportStar(require("./models/kyc"), exports);
43
- __exportStar(require("./models/checked-address"), exports);
43
+ __exportStar(require("./models/crypto-address"), exports);
44
44
  __exportStar(require("./models/fireblocks-vault"), exports);
45
45
  __exportStar(require("./models/fireblocks-transfer"), exports);
46
46
  __exportStar(require("./models/rio-settings"), exports);
@@ -67,7 +67,6 @@ __exportStar(require("./clients/gueno-client"), exports);
67
67
  __exportStar(require("./clients/fireblocks-client"), exports);
68
68
  __exportStar(require("./clients/kapstar-client"), exports);
69
69
  __exportStar(require("./clients/etherscan-client"), exports);
70
- __exportStar(require("./clients/rio-client"), exports);
71
70
  __exportStar(require("./clients/secret-manager-client"), exports);
72
71
  __exportStar(require("./clients/gcloud-storage-client"), exports);
73
72
  __exportStar(require("./clients/currency-api-client"), exports);
@@ -0,0 +1,23 @@
1
+ import { Crypto } from "@riocrypto/common";
2
+ import mongoose from "mongoose";
3
+ interface CryptoAddressAttrs {
4
+ userId: string;
5
+ crypto: Crypto;
6
+ address: string;
7
+ approved: boolean;
8
+ lastChecked: Date;
9
+ label?: string;
10
+ }
11
+ interface CryptoAddressDoc extends mongoose.Document {
12
+ userId: string;
13
+ crypto: Crypto;
14
+ address: string;
15
+ approved: boolean;
16
+ lastChecked: Date;
17
+ label?: string;
18
+ }
19
+ interface CryptoAddressModel extends mongoose.Model<CryptoAddressDoc> {
20
+ build(attrs: CryptoAddressAttrs): CryptoAddressDoc;
21
+ }
22
+ declare const buildCryptoAddress: (mongoose: typeof mongoose) => CryptoAddressModel;
23
+ export { buildCryptoAddress, CryptoAddressDoc };
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildCryptoAddress = void 0;
4
+ const buildCryptoAddress = (mongoose) => {
5
+ // if model is already defined, return it
6
+ if (mongoose.models.CryptoAddress) {
7
+ return mongoose.model("CryptoAddress");
8
+ }
9
+ const CryptoAddressSchema = new mongoose.Schema({
10
+ userId: {
11
+ type: String,
12
+ required: true,
13
+ },
14
+ crypto: {
15
+ type: String,
16
+ required: true,
17
+ },
18
+ address: {
19
+ type: String,
20
+ required: true,
21
+ },
22
+ approved: {
23
+ type: Boolean,
24
+ required: true,
25
+ },
26
+ lastChecked: {
27
+ type: mongoose.Schema.Types.Date,
28
+ required: true,
29
+ },
30
+ label: {
31
+ type: String,
32
+ },
33
+ }, {
34
+ toJSON: {
35
+ transform(doc, ret) {
36
+ ret.id = ret._id;
37
+ delete ret._id;
38
+ delete ret.__v;
39
+ },
40
+ },
41
+ });
42
+ CryptoAddressSchema.statics.build = (attrs) => {
43
+ return new CryptoAddress(attrs);
44
+ };
45
+ const CryptoAddress = mongoose.model("CryptoAddress", CryptoAddressSchema);
46
+ return CryptoAddress;
47
+ };
48
+ exports.buildCryptoAddress = buildCryptoAddress;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1095",
3
+ "version": "1.0.1097",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -25,7 +25,7 @@
25
25
  "@aws-sdk/client-s3": "^3.297.0",
26
26
  "@everapi/currencyapi-js": "^1.0.6",
27
27
  "@google-cloud/storage": "^6.9.5",
28
- "@riocrypto/common": "^1.0.929",
28
+ "@riocrypto/common": "^1.0.936",
29
29
  "@types/express": "^4.17.13",
30
30
  "axios": "^0.27.2",
31
31
  "ccxt": "^3.0.30",
@@ -1,56 +0,0 @@
1
- import { Admin, Auth, AuthUpdate, BankPayout, CheckedAddress, Country, Fiat, Order, OrderInput, PaymentMethod, PayoutMethod, RioSettings, RioSettingsUpdate, SecurityQuestion, User, UserInput, UserUpdate } from "@riocrypto/common";
2
- import { AxiosInstance, AxiosStatic } from "axios";
3
- export declare class RioClient {
4
- private axios;
5
- constructor(axios: AxiosStatic | AxiosInstance);
6
- getOrders(): Promise<Order[]>;
7
- getUsers(): Promise<User[]>;
8
- signin(email: string, password: string): Promise<any>;
9
- updateUser(update: UserUpdate, userId?: string): Promise<User>;
10
- updateAdminUserPassword({ password, newPassword, }: {
11
- password: string;
12
- newPassword: string;
13
- }): Promise<Admin>;
14
- getAdminUser(): Promise<any>;
15
- signoutAdmin(): Promise<void>;
16
- getRioSettings(): Promise<RioSettings>;
17
- createRioSettings(rioSettings: {
18
- platformFee: number;
19
- }): Promise<void>;
20
- updateRioSettings(update: RioSettingsUpdate): Promise<void>;
21
- confirmBankPayment(orderId: string): Promise<any>;
22
- getUser(): Promise<User>;
23
- createUser(user: UserInput): Promise<void>;
24
- createBrokerCustomer(userInput: UserInput): Promise<User>;
25
- sendPhoneAuthCode(phoneNumber: string): Promise<void>;
26
- authExists(phoneNumber: string): Promise<boolean>;
27
- uploadCOI(userId: string, formData: FormData): Promise<User>;
28
- uploadKYCReport(userId: string, formData: FormData): Promise<User>;
29
- getSecurityQuestion(): Promise<SecurityQuestion>;
30
- signout(): Promise<void>;
31
- verifyPhoneCode(phoneNumber: string, code: string): Promise<void>;
32
- createAuth(password: string): Promise<void>;
33
- createOrder(order: OrderInput): Promise<Order>;
34
- getOrder(id: string): Promise<Order>;
35
- initBankPayout(oid: string, accountNumber: string): Promise<BankPayout>;
36
- getBankPayout(orderId: string): Promise<BankPayout>;
37
- checkAddress(address: string, crypto: Crypto): Promise<CheckedAddress>;
38
- getSupportedPaymentMethods(fiat: Fiat, country: Country): Promise<PaymentMethod[]>;
39
- getSupportedPayoutMethods(fiat: Fiat, country: Country): Promise<PayoutMethod[]>;
40
- createClipCardPayment(orderId: string): Promise<{
41
- paymentId: string;
42
- paymentRequestUrl: string;
43
- }>;
44
- createConektaPayment(orderId: string): Promise<{
45
- checkoutRequestId: string;
46
- }>;
47
- createKushkiPayment(orderId: string, token: string): Promise<{
48
- paymentId: string;
49
- }>;
50
- createKushkiBankPayment(orderId: string): Promise<any>;
51
- createSPEIPayment(orderId: string): Promise<any>;
52
- createSPIDPayment(orderId: string): Promise<any>;
53
- createSWIFTPayment(orderId: string): Promise<any>;
54
- createInterbankPayment(orderId: string): Promise<any>;
55
- updateAuth(update: AuthUpdate, id?: string): Promise<Auth>;
56
- }
@@ -1,279 +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
- signin(email, password) {
30
- return __awaiter(this, void 0, void 0, function* () {
31
- const { data } = yield this.axios.post(`/api/admin/signin`, {
32
- email,
33
- password,
34
- });
35
- return data;
36
- });
37
- }
38
- updateUser(update, userId) {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- const { data } = yield this.axios.patch(`/api/users/${userId}`, update);
41
- return data;
42
- });
43
- }
44
- updateAdminUserPassword({ password, newPassword, }) {
45
- return __awaiter(this, void 0, void 0, function* () {
46
- const { data } = yield this.axios.patch(`/api/admin`, {
47
- password,
48
- newPassword,
49
- });
50
- return data;
51
- });
52
- }
53
- getAdminUser() {
54
- return __awaiter(this, void 0, void 0, function* () {
55
- const { data } = yield this.axios.get(`/api/admin`);
56
- return data;
57
- });
58
- }
59
- signoutAdmin() {
60
- return __awaiter(this, void 0, void 0, function* () {
61
- yield this.axios.post("/api/admin/signout", {});
62
- });
63
- }
64
- getRioSettings() {
65
- return __awaiter(this, void 0, void 0, function* () {
66
- const { data } = yield this.axios.get(`/api/settings`);
67
- return data;
68
- });
69
- }
70
- createRioSettings(rioSettings) {
71
- return __awaiter(this, void 0, void 0, function* () {
72
- yield this.axios.post(`/api/settings`, rioSettings);
73
- });
74
- }
75
- updateRioSettings(update) {
76
- return __awaiter(this, void 0, void 0, function* () {
77
- const { data } = yield this.axios.patch(`/api/settings`, update);
78
- return data;
79
- });
80
- }
81
- confirmBankPayment(orderId) {
82
- return __awaiter(this, void 0, void 0, function* () {
83
- const { data } = yield this.axios.post(`/api/payments/bank/confirm`, {
84
- orderId,
85
- });
86
- return data;
87
- });
88
- }
89
- getUser() {
90
- return __awaiter(this, void 0, void 0, function* () {
91
- const { data } = yield this.axios.get("/api/users/current");
92
- return data;
93
- });
94
- }
95
- createUser(user) {
96
- return __awaiter(this, void 0, void 0, function* () {
97
- yield this.axios.post("/api/users/current-auth", user);
98
- });
99
- }
100
- createBrokerCustomer(userInput) {
101
- return __awaiter(this, void 0, void 0, function* () {
102
- const response = yield this.axios.post("/api/users/broker-customers/current-auth", userInput);
103
- return response.data;
104
- });
105
- }
106
- sendPhoneAuthCode(phoneNumber) {
107
- return __awaiter(this, void 0, void 0, function* () {
108
- yield this.axios.post("/api/auth/sendCode", {
109
- phoneNumber,
110
- });
111
- });
112
- }
113
- authExists(phoneNumber) {
114
- return __awaiter(this, void 0, void 0, function* () {
115
- const response = yield this.axios.post("/api/auth/exists", {
116
- phoneNumber,
117
- });
118
- return response.data.exists;
119
- });
120
- }
121
- uploadCOI(userId, formData) {
122
- return __awaiter(this, void 0, void 0, function* () {
123
- const { data } = yield this.axios.patch(`/api/users/${userId}/coi`, formData);
124
- return data;
125
- });
126
- }
127
- uploadKYCReport(userId, formData) {
128
- return __awaiter(this, void 0, void 0, function* () {
129
- const { data } = yield this.axios.patch(`/api/users/${userId}/kyc-report`, formData);
130
- return data;
131
- });
132
- }
133
- getSecurityQuestion() {
134
- return __awaiter(this, void 0, void 0, function* () {
135
- const response = yield this.axios.get("/api/auth/security-question", {});
136
- return response.data.question;
137
- });
138
- }
139
- signout() {
140
- return __awaiter(this, void 0, void 0, function* () {
141
- yield this.axios.post("/api/auth/signout", {});
142
- });
143
- }
144
- verifyPhoneCode(phoneNumber, code) {
145
- return __awaiter(this, void 0, void 0, function* () {
146
- yield this.axios.post("/api/auth/verifycode", {
147
- phoneNumber,
148
- code,
149
- });
150
- });
151
- }
152
- createAuth(password) {
153
- return __awaiter(this, void 0, void 0, function* () {
154
- yield this.axios.post("/api/auth", {
155
- password,
156
- });
157
- });
158
- }
159
- createOrder(order) {
160
- return __awaiter(this, void 0, void 0, function* () {
161
- const response = yield this.axios.post("/api/orders", order);
162
- return response.data;
163
- });
164
- }
165
- getOrder(id) {
166
- return __awaiter(this, void 0, void 0, function* () {
167
- const response = yield this.axios.get(`/api/orders/${id}`);
168
- return response.data;
169
- });
170
- }
171
- initBankPayout(oid, accountNumber) {
172
- return __awaiter(this, void 0, void 0, function* () {
173
- const response = yield this.axios.post(`/api/payouts/bank`, {
174
- orderId: oid,
175
- accountNumber,
176
- });
177
- return response.data;
178
- });
179
- }
180
- getBankPayout(orderId) {
181
- return __awaiter(this, void 0, void 0, function* () {
182
- const response = yield this.axios.get(`/api/payouts/bank?orderId=${orderId}`);
183
- return response.data;
184
- });
185
- }
186
- checkAddress(address, crypto) {
187
- return __awaiter(this, void 0, void 0, function* () {
188
- const response = yield this.axios.post(`/api/kyt/address`, {
189
- address,
190
- crypto,
191
- });
192
- return response.data;
193
- });
194
- }
195
- getSupportedPaymentMethods(fiat, country) {
196
- return __awaiter(this, void 0, void 0, function* () {
197
- const response = yield this.axios.get(`/api/payment-methods/supported?fiat=${fiat}&country=${country}`);
198
- return response.data;
199
- });
200
- }
201
- getSupportedPayoutMethods(fiat, country) {
202
- return __awaiter(this, void 0, void 0, function* () {
203
- const response = yield this.axios.get(`/api/payout-methods/supported?fiat=${fiat}&country=${country}`);
204
- return response.data;
205
- });
206
- }
207
- createClipCardPayment(orderId) {
208
- return __awaiter(this, void 0, void 0, function* () {
209
- const { data } = yield this.axios.post(`/api/payments/card/clip`, {
210
- orderId,
211
- });
212
- return data;
213
- });
214
- }
215
- createConektaPayment(orderId) {
216
- return __awaiter(this, void 0, void 0, function* () {
217
- const { data } = yield this.axios.post(`/api/payments/card/conekta`, {
218
- orderId,
219
- });
220
- return data;
221
- });
222
- }
223
- createKushkiPayment(orderId, token) {
224
- return __awaiter(this, void 0, void 0, function* () {
225
- const { data } = yield this.axios.post(`/api/payments/card/kushki`, {
226
- orderId,
227
- token,
228
- });
229
- return data;
230
- });
231
- }
232
- createKushkiBankPayment(orderId) {
233
- return __awaiter(this, void 0, void 0, function* () {
234
- const { data } = yield this.axios.post(`/api/payments/bank/kushki`, {
235
- orderId,
236
- });
237
- return data;
238
- });
239
- }
240
- createSPEIPayment(orderId) {
241
- return __awaiter(this, void 0, void 0, function* () {
242
- const { data } = yield this.axios.post(`/api/payments/bank/spei`, {
243
- orderId,
244
- });
245
- return data;
246
- });
247
- }
248
- createSPIDPayment(orderId) {
249
- return __awaiter(this, void 0, void 0, function* () {
250
- const { data } = yield this.axios.post(`/api/payments/bank/spid`, {
251
- orderId,
252
- });
253
- return data;
254
- });
255
- }
256
- createSWIFTPayment(orderId) {
257
- return __awaiter(this, void 0, void 0, function* () {
258
- const { data } = yield this.axios.post(`/api/payments/bank/swift`, {
259
- orderId,
260
- });
261
- return data;
262
- });
263
- }
264
- createInterbankPayment(orderId) {
265
- return __awaiter(this, void 0, void 0, function* () {
266
- const { data } = yield this.axios.post(`/api/payments/bank/interbank`, {
267
- orderId,
268
- });
269
- return data;
270
- });
271
- }
272
- updateAuth(update, id) {
273
- return __awaiter(this, void 0, void 0, function* () {
274
- const { data } = yield this.axios.patch(`/api/auth/${id}`, update);
275
- return data;
276
- });
277
- }
278
- }
279
- exports.RioClient = RioClient;
@@ -1,17 +0,0 @@
1
- import { AddressCheckResult } from "@riocrypto/common";
2
- import mongoose from "mongoose";
3
- interface CheckedAddressAttrs {
4
- address: string;
5
- result: AddressCheckResult;
6
- lastChecked: Date;
7
- }
8
- interface CheckedAddressDoc extends mongoose.Document {
9
- address: string;
10
- result: AddressCheckResult;
11
- lastChecked: Date;
12
- }
13
- interface CheckedAddressModel extends mongoose.Model<CheckedAddressDoc> {
14
- build(attrs: CheckedAddressAttrs): CheckedAddressDoc;
15
- }
16
- declare const buildCheckedAddress: (mongoose: typeof mongoose) => CheckedAddressModel;
17
- export { buildCheckedAddress, CheckedAddressDoc };
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildCheckedAddress = void 0;
4
- const buildCheckedAddress = (mongoose) => {
5
- // if model is already defined, return it
6
- if (mongoose.models.CheckedAddress) {
7
- return mongoose.model("CheckedAddress");
8
- }
9
- const CheckedAddressSchema = new mongoose.Schema({
10
- address: {
11
- type: String,
12
- required: true,
13
- },
14
- result: {
15
- type: String,
16
- required: true,
17
- },
18
- lastChecked: {
19
- type: mongoose.Schema.Types.Date,
20
- required: true,
21
- },
22
- }, {
23
- toJSON: {
24
- transform(doc, ret) {
25
- ret.id = ret._id;
26
- delete ret._id;
27
- delete ret.__v;
28
- },
29
- },
30
- });
31
- CheckedAddressSchema.statics.build = (attrs) => {
32
- return new CheckedAddress(attrs);
33
- };
34
- const CheckedAddress = mongoose.model("CheckedAddress", CheckedAddressSchema);
35
- return CheckedAddress;
36
- };
37
- exports.buildCheckedAddress = buildCheckedAddress;