@riocrypto/common-server 1.0.1383 → 1.0.1390

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.
@@ -23,15 +23,19 @@ class InvopopClient {
23
23
  this.baseUrl = "https://api.invopop.com";
24
24
  }
25
25
  createJob(order, user) {
26
- var _a, _b;
26
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
27
27
  return __awaiter(this, void 0, void 0, function* () {
28
28
  const uuid = (0, uuid_1.v1)();
29
29
  const operationDate = new Date(order.createdAt);
30
- const operationDateOptions = { timeZone: "America/Mexico_City" };
31
- const operationDateFormatted = operationDate.toLocaleString("en-US", operationDateOptions);
30
+ const operationYear = operationDate.getFullYear();
31
+ const operationMonth = String(operationDate.getMonth() + 1).padStart(2, "0"); // Month is zero-indexed
32
+ const operationDay = String(operationDate.getDate()).padStart(2, "0");
33
+ const operationDateFormatted = `${operationYear}-${operationMonth}-${operationDay}`;
32
34
  const issueDate = new Date();
33
- const issueDateOptions = { timeZone: "America/Mexico_City" };
34
- const issueDateFormatted = issueDate.toLocaleString("en-US", issueDateOptions);
35
+ const issueYear = issueDate.getFullYear();
36
+ const issueMonth = String(issueDate.getMonth() + 1).padStart(2, "0"); // Month is zero-indexed
37
+ const issueDay = String(issueDate.getDate()).padStart(2, "0");
38
+ const issueDateFormatted = `${issueYear}-${issueMonth}-${issueDay}`;
35
39
  const { data } = yield axios_1.default.put(`${this.baseUrl}/transform/v1/jobs/${uuid}`, {
36
40
  workflow_id: "5b123900-1035-4c8c-a97a-36b940d7a21e",
37
41
  data: {
@@ -56,22 +60,24 @@ class InvopopClient {
56
60
  ],
57
61
  },
58
62
  customer: {
59
- name: user.mexicoFiscalName
60
- ? user.mexicoFiscalName.toLocaleUpperCase()
63
+ name: ((_a = user.invoicing) === null || _a === void 0 ? void 0 : _a.MX.fiscalName)
64
+ ? (_b = user.invoicing) === null || _b === void 0 ? void 0 : _b.MX.fiscalName.toLocaleUpperCase()
61
65
  : (0, common_1.getUserName)(user),
62
66
  tax_id: {
63
67
  country: "MX",
64
- zone: user.rfc ? user.postalCode : "66260",
65
- code: user.rfc || "XAXX010101000",
68
+ zone: ((_c = user.invoicing) === null || _c === void 0 ? void 0 : _c.MX.shouldInvoice)
69
+ ? user.address.postalCode
70
+ : "66260",
71
+ code: ((_e = (_d = user.KYC) === null || _d === void 0 ? void 0 : _d.MX) === null || _e === void 0 ? void 0 : _e.taxId) || "XAXX010101000",
66
72
  },
67
73
  identities: [
68
74
  {
69
75
  key: "mx-cfdi-fiscal-regime",
70
- code: ((_a = user.mexicoFiscalRegimenCode) === null || _a === void 0 ? void 0 : _a.toString()) || "616",
76
+ code: ((_g = (_f = user.invoicing) === null || _f === void 0 ? void 0 : _f.MX.fiscalRegimenCode) === null || _g === void 0 ? void 0 : _g.toString()) || "616",
71
77
  },
72
78
  {
73
79
  key: "mx-cfdi-use",
74
- code: user.rfc ? "G03" : "S01",
80
+ code: ((_h = user.invoicing) === null || _h === void 0 ? void 0 : _h.MX.shouldInvoice) ? "G03" : "S01",
75
81
  },
76
82
  ],
77
83
  },
@@ -82,7 +88,7 @@ class InvopopClient {
82
88
  item: {
83
89
  name: "Facilitación de Compra-Venta de Activos Virtuales",
84
90
  identities: [{ key: "mx-cfdi-prod-serv", code: "80151500" }],
85
- price: (_b = order.actualFees.platformFeeFiat) === null || _b === void 0 ? void 0 : _b.toFixed(2),
91
+ price: (_j = order.actualFees.platformFeeFiat) === null || _j === void 0 ? void 0 : _j.toFixed(2),
86
92
  },
87
93
  taxes: [
88
94
  {
@@ -35,12 +35,13 @@ class KapstarClient {
35
35
  });
36
36
  }
37
37
  createInvoice(amount, orderId, user) {
38
+ var _a, _b;
38
39
  return __awaiter(this, void 0, void 0, function* () {
39
40
  const kapstarResponse = yield this.axiosInstance.post("/transaction-service/v1/external/invoice", {
40
41
  amount,
41
42
  name: (0, common_1.getUserName)(user),
42
43
  tags: [orderId],
43
- tax_id: user.cpf,
44
+ tax_id: (_b = (_a = user.KYC) === null || _a === void 0 ? void 0 : _a.BR) === null || _b === void 0 ? void 0 : _b.taxId,
44
45
  });
45
46
  return kapstarResponse.data;
46
47
  });
@@ -43,7 +43,7 @@ class KillbClient {
43
43
  }
44
44
  createUser(user) {
45
45
  return __awaiter(this, void 0, void 0, function* () {
46
- const dateOfBirth = this.formatDateToYYYYMMDD(new Date(user.birthday));
46
+ const dateOfBirth = this.formatDateToYYYYMMDD(new Date(user.individualData.birthday));
47
47
  const { data } = yield axios_1.default.post(`${this.baseUrl}/api/v1/auth/login`, {
48
48
  email: this.username,
49
49
  paassword: this.password,
@@ -20,15 +20,15 @@ const getUserTransactionLimits = (mongoose, id) => __awaiter(void 0, void 0, voi
20
20
  throw new common_1.NotFoundError("User");
21
21
  }
22
22
  const { volume } = yield (0, calculate_aggregate_volume_and_revenue_1.calculateAggregateVolumeAndRevenue)(mongoose, 30, user, true);
23
- const { riskTier } = user;
23
+ const { risk } = user;
24
24
  let limit = 0;
25
- if (riskTier === common_1.RiskTier.High) {
25
+ if (risk === common_1.RiskTier.High) {
26
26
  limit = 3000;
27
27
  }
28
- else if (riskTier === common_1.RiskTier.Medium) {
28
+ else if (risk === common_1.RiskTier.Medium) {
29
29
  limit = 75000;
30
30
  }
31
- else if (riskTier === common_1.RiskTier.Low) {
31
+ else if (risk === common_1.RiskTier.Low) {
32
32
  if (user.hasPassedEDD) {
33
33
  limit = 100000000;
34
34
  }
package/build/index.d.ts CHANGED
@@ -43,7 +43,6 @@ export * from "./models/market-data";
43
43
  export * from "./models/telegram-session";
44
44
  export * from "./clients/bitstamp-client";
45
45
  export * from "./clients/ccxt-client";
46
- export * from "./clients/kushki-client";
47
46
  export * from "./clients/slack-client";
48
47
  export * from "./clients/gueno-client";
49
48
  export * from "./clients/fireblocks-client";
package/build/index.js CHANGED
@@ -59,7 +59,6 @@ __exportStar(require("./models/market-data"), exports);
59
59
  __exportStar(require("./models/telegram-session"), exports);
60
60
  __exportStar(require("./clients/bitstamp-client"), exports);
61
61
  __exportStar(require("./clients/ccxt-client"), exports);
62
- __exportStar(require("./clients/kushki-client"), exports);
63
62
  __exportStar(require("./clients/slack-client"), exports);
64
63
  __exportStar(require("./clients/gueno-client"), exports);
65
64
  __exportStar(require("./clients/fireblocks-client"), exports);
@@ -22,7 +22,7 @@ const secret_manager_client_1 = require("../clients/secret-manager-client");
22
22
  const admin_1 = require("../models/admin");
23
23
  const admin_auth_1 = require("../models/admin-auth");
24
24
  const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(void 0, void 0, void 0, function* () {
25
- var _a, _b, _c, _d;
25
+ var _a, _b, _c, _d, _e, _f, _g, _h;
26
26
  if (authorizationTypes.includes(common_1.AuthorizationType.Cluster)) {
27
27
  let apiKey = req.header("x-cluster-api-key");
28
28
  const CLUSTER_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("CLUSTER_API_KEY");
@@ -126,7 +126,8 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
126
126
  req.user = user;
127
127
  }
128
128
  else {
129
- if (user.kycStatus === common_1.KYCStatus.Approved) {
129
+ if (((_f = (_e = user.KYC) === null || _e === void 0 ? void 0 : _e.MX) === null || _f === void 0 ? void 0 : _f.status) === common_1.KYCStatus.Approved ||
130
+ ((_h = (_g = user.KYC) === null || _g === void 0 ? void 0 : _g.PE) === null || _h === void 0 ? void 0 : _h.status) === common_1.KYCStatus.Approved) {
130
131
  req.user = user;
131
132
  }
132
133
  }
@@ -1,38 +1,37 @@
1
- import { Country, KYCStatus, Language, PlatformFeeRange, USState, UserAttribute, UserType, CountryOfOrigin, RiskTier } from "@riocrypto/common";
1
+ import { KYCStatus, PlatformFeeRange, UserAttribute, UserType, CountryOfOrigin, RiskTier } from "@riocrypto/common";
2
2
  import { Mongoose, Model, Document } from "mongoose";
3
3
  interface UserAttrs {
4
4
  createdAt: Date;
5
5
  authIds?: string[];
6
+ brokerId?: string;
6
7
  type: UserType;
7
8
  phoneNumber: string;
8
9
  email: string;
9
- street1: string;
10
- street2?: string;
11
- city: string;
12
- state: USState | string;
13
- postalCode: string;
14
- country: CountryOfOrigin;
15
- kycStatus: KYCStatus;
16
- riskTier: RiskTier;
10
+ individualData?: {
11
+ firstName: string;
12
+ middleName?: string;
13
+ lastName: string;
14
+ secondLastName?: string;
15
+ birthday: Date;
16
+ countryOfOrigin: CountryOfOrigin;
17
+ };
18
+ businessData?: {
19
+ businessName: string;
20
+ legalRepresentative?: {
21
+ name: string;
22
+ status?: string;
23
+ };
24
+ UBO?: {
25
+ name: string;
26
+ id?: string;
27
+ status?: string;
28
+ };
29
+ };
30
+ risk: RiskTier;
17
31
  hasPassedEDD: boolean;
18
- firstName?: string;
19
- middleName?: string;
20
- lastName?: string;
21
- secondLastName?: string;
22
- companyName?: string;
23
- birthday?: Date;
24
32
  cosignerGroupId?: string;
25
- legalRepresentative?: string;
26
- cpf?: string;
27
- CPF?: string;
28
- language?: Language;
29
33
  attributes?: UserAttribute[];
30
- brokerId?: string;
31
- curp?: string;
32
- ruc?: string;
33
- CURP?: string;
34
- RUC?: string;
35
- economicActivity?: string;
34
+ authorizedPhoneNumbers?: string[];
36
35
  platformFeeRanges?: {
37
36
  MX?: {
38
37
  buy?: PlatformFeeRange[];
@@ -55,19 +54,81 @@ interface UserAttrs {
55
54
  sell?: PlatformFeeRange[];
56
55
  };
57
56
  };
58
- COIFile?: string;
59
- KYCReportFile?: string;
60
- CSFFile?: string;
61
- proofOfAddressFile?: string;
62
- authorizedPhoneNumbers?: string[];
63
- notificationUrl?: string;
64
- rfc?: string;
65
- RFC?: string;
66
- countriesToInvoice?: Country[];
67
- mexicoFiscalRegimenCode?: number;
68
- mexicoFiscalName?: string;
69
- taxId?: string;
70
- usKYCStatus?: "none" | "pending" | "failed" | "approved";
57
+ KYC?: {
58
+ MX?: {
59
+ status: KYCStatus;
60
+ personalId?: string;
61
+ taxId: string;
62
+ files?: {
63
+ certificateOfIncorporation?: string;
64
+ kycReport?: string;
65
+ taxTranscript?: string;
66
+ proofOfAddress?: string;
67
+ businessRegistration?: string;
68
+ taxIdentificationCertificate?: string;
69
+ legalRepresentativeIdPowerOfAttorney?: string;
70
+ personalIdentificationCertificate?: string;
71
+ extraFiles?: string[];
72
+ };
73
+ };
74
+ PE?: {
75
+ status: KYCStatus;
76
+ personalId?: string;
77
+ taxId?: string;
78
+ files?: {
79
+ certificateOfIncorporation?: string;
80
+ kycReport?: string;
81
+ taxTranscript?: string;
82
+ proofOfAddress?: string;
83
+ businessRegistration?: string;
84
+ taxIdentificationCertificate?: string;
85
+ legalRepresentativeIdPowerOfAttorney?: string;
86
+ personalIdentificationCertificate?: string;
87
+ extraFiles?: string[];
88
+ };
89
+ };
90
+ US?: {
91
+ status: KYCStatus;
92
+ personalId?: string;
93
+ taxId?: string;
94
+ files?: {
95
+ certificateOfIncorporation?: string;
96
+ kycReport?: string;
97
+ extraFiles?: string[];
98
+ };
99
+ };
100
+ BR?: {
101
+ status: KYCStatus;
102
+ personalId?: string;
103
+ taxId?: string;
104
+ files?: {
105
+ certificateOfIncorporation?: string;
106
+ kycReport?: string;
107
+ taxTranscript?: string;
108
+ proofOfAddress?: string;
109
+ businessRegistration?: string;
110
+ taxIdentificationCertificate?: string;
111
+ legalRepresentativeIdPowerOfAttorney?: string;
112
+ personalIdentificationCertificate?: string;
113
+ extraFiles?: string[];
114
+ };
115
+ };
116
+ };
117
+ address: {
118
+ street1: string;
119
+ street2?: string;
120
+ city: string;
121
+ state: string;
122
+ postalCode: string;
123
+ country: CountryOfOrigin;
124
+ };
125
+ invoicing?: {
126
+ MX: {
127
+ shouldInvoice: boolean;
128
+ fiscalName?: string;
129
+ fiscalRegimenCode?: number;
130
+ };
131
+ };
71
132
  }
72
133
  interface UserModel extends Model<UserDoc> {
73
134
  build(attrs: UserAttrs): UserDoc;
@@ -76,37 +137,35 @@ interface UserDoc extends Document {
76
137
  _id: string;
77
138
  createdAt: Date;
78
139
  authIds?: string[];
140
+ brokerId?: string;
79
141
  type: UserType;
80
142
  phoneNumber: string;
81
143
  email: string;
82
- street1: string;
83
- street2?: string;
84
- city: string;
85
- state: USState | string;
86
- postalCode: string;
87
- country: CountryOfOrigin;
88
- kycStatus: KYCStatus;
89
- riskTier: RiskTier;
144
+ individualData?: {
145
+ firstName: string;
146
+ middleName?: string;
147
+ lastName: string;
148
+ secondLastName?: string;
149
+ birthday: Date;
150
+ countryOfOrigin: CountryOfOrigin;
151
+ };
152
+ businessData?: {
153
+ businessName: string;
154
+ legalRepresentative?: {
155
+ name: string;
156
+ status?: string;
157
+ };
158
+ UBO?: {
159
+ name: string;
160
+ id?: string;
161
+ status?: string;
162
+ };
163
+ };
164
+ risk: RiskTier;
90
165
  hasPassedEDD: boolean;
91
- firstName?: string;
92
- middleName?: string;
93
- lastName?: string;
94
- secondLastName?: string;
95
166
  cosignerGroupId?: string;
96
- companyName?: string;
97
- legalRepresentative?: string;
98
- cpf?: string;
99
- curp?: string;
100
- ruc?: string;
101
- CPF?: string;
102
- CURP?: string;
103
- RUC?: string;
104
- economicActivity?: string;
105
- birthday?: Date;
106
- language?: Language;
107
- countriesToInvoice?: Country[];
108
167
  attributes?: UserAttribute[];
109
- brokerId?: string;
168
+ authorizedPhoneNumbers?: string[];
110
169
  platformFeeRanges?: {
111
170
  MX?: {
112
171
  buy?: PlatformFeeRange[];
@@ -129,18 +188,81 @@ interface UserDoc extends Document {
129
188
  sell?: PlatformFeeRange[];
130
189
  };
131
190
  };
132
- COIFile?: string;
133
- KYCReportFile?: string;
134
- CSFFile?: string;
135
- proofOfAddressFile?: string;
136
- authorizedPhoneNumbers?: string[];
137
- notificationUrl?: string;
138
- rfc?: string;
139
- RFC?: string;
140
- mexicoFiscalRegimenCode?: number;
141
- mexicoFiscalName?: string;
142
- taxId?: string;
143
- usKYCStatus?: "none" | "pending" | "failed" | "approved";
191
+ KYC?: {
192
+ MX?: {
193
+ status: KYCStatus;
194
+ personalId?: string;
195
+ taxId: string;
196
+ files?: {
197
+ certificateOfIncorporation?: string;
198
+ kycReport?: string;
199
+ taxTranscript?: string;
200
+ proofOfAddress?: string;
201
+ businessRegistration?: string;
202
+ taxIdentificationCertificate?: string;
203
+ legalRepresentativeIdPowerOfAttorney?: string;
204
+ personalIdentificationCertificate?: string;
205
+ extraFiles?: string[];
206
+ };
207
+ };
208
+ PE?: {
209
+ status: KYCStatus;
210
+ personalId?: string;
211
+ taxId?: string;
212
+ files?: {
213
+ certificateOfIncorporation?: string;
214
+ kycReport?: string;
215
+ taxTranscript?: string;
216
+ proofOfAddress?: string;
217
+ businessRegistration?: string;
218
+ taxIdentificationCertificate?: string;
219
+ legalRepresentativeIdPowerOfAttorney?: string;
220
+ personalIdentificationCertificate?: string;
221
+ extraFiles?: string[];
222
+ };
223
+ };
224
+ US?: {
225
+ status: KYCStatus;
226
+ personalId?: string;
227
+ taxId?: string;
228
+ files?: {
229
+ certificateOfIncorporation?: string;
230
+ kycReport?: string;
231
+ extraFiles?: string[];
232
+ };
233
+ };
234
+ BR?: {
235
+ status: KYCStatus;
236
+ personalId?: string;
237
+ taxId?: string;
238
+ files?: {
239
+ certificateOfIncorporation?: string;
240
+ kycReport?: string;
241
+ taxTranscript?: string;
242
+ proofOfAddress?: string;
243
+ businessRegistration?: string;
244
+ taxIdentificationCertificate?: string;
245
+ legalRepresentativeIdPowerOfAttorney?: string;
246
+ personalIdentificationCertificate?: string;
247
+ extraFiles?: string[];
248
+ };
249
+ };
250
+ };
251
+ address: {
252
+ street1: string;
253
+ street2?: string;
254
+ city: string;
255
+ state: string;
256
+ postalCode: string;
257
+ country: CountryOfOrigin;
258
+ };
259
+ invoicing?: {
260
+ MX: {
261
+ shouldInvoice: boolean;
262
+ fiscalName?: string;
263
+ fiscalRegimenCode?: number;
264
+ };
265
+ };
144
266
  }
145
267
  declare const buildUser: (mongoose: Mongoose) => UserModel;
146
268
  export { buildUser, UserDoc };
@@ -70,7 +70,7 @@ const buildUser = (mongoose) => {
70
70
  type: String,
71
71
  required: true,
72
72
  },
73
- riskTier: {
73
+ risk: {
74
74
  type: String,
75
75
  required: true,
76
76
  },
@@ -110,6 +110,14 @@ const buildUser = (mongoose) => {
110
110
  type: String,
111
111
  required: true,
112
112
  },
113
+ status: {
114
+ local: {
115
+ type: String,
116
+ },
117
+ US: {
118
+ type: String,
119
+ },
120
+ },
113
121
  brokerId: {
114
122
  type: String,
115
123
  },
@@ -335,6 +343,244 @@ const buildUser = (mongoose) => {
335
343
  usKYCStatus: {
336
344
  type: String,
337
345
  },
346
+ address: {
347
+ street1: {
348
+ type: String,
349
+ required: true,
350
+ },
351
+ street2: {
352
+ type: String,
353
+ },
354
+ city: {
355
+ type: String,
356
+ required: true,
357
+ },
358
+ state: {
359
+ type: String,
360
+ required: true,
361
+ },
362
+ postalCode: {
363
+ type: String,
364
+ required: true,
365
+ },
366
+ country: {
367
+ type: String,
368
+ required: true,
369
+ },
370
+ },
371
+ KYC: {
372
+ MX: {
373
+ status: {
374
+ type: String,
375
+ required: true,
376
+ },
377
+ personalId: {
378
+ type: String,
379
+ },
380
+ taxId: {
381
+ type: String,
382
+ },
383
+ files: {
384
+ certificateOfIncorporation: {
385
+ type: String,
386
+ },
387
+ kycReport: {
388
+ type: String,
389
+ },
390
+ taxTranscript: {
391
+ type: String,
392
+ },
393
+ proofOfAddress: {
394
+ type: String,
395
+ },
396
+ businessRegistration: {
397
+ type: String,
398
+ },
399
+ taxIdentificationCertificate: {
400
+ type: String,
401
+ },
402
+ legalRepresentativeIdPowerOfAttorney: {
403
+ type: String,
404
+ },
405
+ personalIdentificationCertificate: {
406
+ type: String,
407
+ },
408
+ extraFiles: [
409
+ {
410
+ type: String,
411
+ },
412
+ ],
413
+ },
414
+ },
415
+ PE: {
416
+ status: {
417
+ type: String,
418
+ required: true,
419
+ },
420
+ personalId: {
421
+ type: String,
422
+ },
423
+ taxId: {
424
+ type: String,
425
+ },
426
+ files: {
427
+ certificateOfIncorporation: {
428
+ type: String,
429
+ },
430
+ kycReport: {
431
+ type: String,
432
+ },
433
+ taxTranscript: {
434
+ type: String,
435
+ },
436
+ proofOfAddress: {
437
+ type: String,
438
+ },
439
+ businessRegistration: {
440
+ type: String,
441
+ },
442
+ taxIdentificationCertificate: {
443
+ type: String,
444
+ },
445
+ legalRepresentativeIdPowerOfAttorney: {
446
+ type: String,
447
+ },
448
+ personalIdentificationCertificate: {
449
+ type: String,
450
+ },
451
+ extraFiles: [
452
+ {
453
+ type: String,
454
+ },
455
+ ],
456
+ },
457
+ },
458
+ US: {
459
+ status: {
460
+ type: String,
461
+ required: true,
462
+ },
463
+ personalId: {
464
+ type: String,
465
+ },
466
+ taxId: {
467
+ type: String,
468
+ },
469
+ files: {
470
+ certificateOfIncorporation: {
471
+ type: String,
472
+ },
473
+ kycReport: {
474
+ type: String,
475
+ },
476
+ extraFiles: [
477
+ {
478
+ type: String,
479
+ },
480
+ ],
481
+ },
482
+ },
483
+ BR: {
484
+ status: {
485
+ type: String,
486
+ required: true,
487
+ },
488
+ personalId: {
489
+ type: String,
490
+ },
491
+ taxId: {
492
+ type: String,
493
+ },
494
+ files: {
495
+ certificateOfIncorporation: {
496
+ type: String,
497
+ },
498
+ kycReport: {
499
+ type: String,
500
+ },
501
+ taxTranscript: {
502
+ type: String,
503
+ },
504
+ proofOfAddress: {
505
+ type: String,
506
+ },
507
+ businessRegistration: {
508
+ type: String,
509
+ },
510
+ taxIdentificationCertificate: {
511
+ type: String,
512
+ },
513
+ legalRepresentativeIdPowerOfAttorney: {
514
+ type: String,
515
+ },
516
+ personalIdentificationCertificate: {
517
+ type: String,
518
+ },
519
+ extraFiles: [
520
+ {
521
+ type: String,
522
+ },
523
+ ],
524
+ },
525
+ },
526
+ },
527
+ invoicing: {
528
+ MX: {
529
+ shouldInvoice: {
530
+ type: Boolean,
531
+ },
532
+ fiscalName: {
533
+ type: String,
534
+ },
535
+ fiscalRegimenCode: {
536
+ type: Number,
537
+ },
538
+ },
539
+ },
540
+ businessData: {
541
+ businessName: {
542
+ type: String,
543
+ },
544
+ legalRepresentative: {
545
+ name: {
546
+ type: String,
547
+ },
548
+ status: {
549
+ type: String,
550
+ },
551
+ },
552
+ UBO: {
553
+ name: {
554
+ type: String,
555
+ },
556
+ id: {
557
+ type: String,
558
+ },
559
+ status: {
560
+ type: String,
561
+ },
562
+ },
563
+ },
564
+ individualData: {
565
+ firstName: {
566
+ type: String,
567
+ },
568
+ middleName: {
569
+ type: String,
570
+ },
571
+ lastName: {
572
+ type: String,
573
+ },
574
+ secondLastName: {
575
+ type: String,
576
+ },
577
+ birthday: {
578
+ type: Date,
579
+ },
580
+ countryOfOrigin: {
581
+ type: String,
582
+ },
583
+ },
338
584
  }, {
339
585
  toJSON: {
340
586
  transform(doc, ret) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1383",
3
+ "version": "1.0.1390",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -27,7 +27,7 @@
27
27
  "@everapi/currencyapi-js": "^1.0.6",
28
28
  "@google-cloud/storage": "^6.9.5",
29
29
  "@google-cloud/vision": "^4.0.2",
30
- "@riocrypto/common": "^1.0.1206",
30
+ "@riocrypto/common": "^1.0.1213",
31
31
  "@types/express": "^4.17.13",
32
32
  "axios": "^0.27.2",
33
33
  "ccxt": "^3.0.30",
@@ -1,12 +0,0 @@
1
- import { Order, User } from "@riocrypto/common";
2
- declare class KushkiClient {
3
- private privateMerchantId;
4
- private environment;
5
- private baseUrl;
6
- constructor(privateMerchantId: string, environment: "sandbox" | "production");
7
- createPaymentLink(order: Order, user: User, token: string): Promise<any>;
8
- createBankPaymentToken(order: Order, user: User): Promise<any>;
9
- createBankPayment(order: Order, user: User, token: string): Promise<any>;
10
- }
11
- export declare const buildKushkiClient: () => Promise<KushkiClient>;
12
- export {};
@@ -1,159 +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.buildKushkiClient = void 0;
16
- const common_1 = require("@riocrypto/common");
17
- const axios_1 = __importDefault(require("axios"));
18
- const secret_manager_client_1 = require("./secret-manager-client");
19
- class KushkiClient {
20
- constructor(privateMerchantId, environment) {
21
- this.privateMerchantId = privateMerchantId;
22
- this.environment = environment;
23
- this.baseUrl = `https://api${this.environment === "production" ? "." : "-uat."}kushkipagos.com`;
24
- }
25
- createPaymentLink(order, user, token) {
26
- return __awaiter(this, void 0, void 0, function* () {
27
- const body = {
28
- token,
29
- amount: {
30
- currency: order.fiat,
31
- subtotalIva: 0,
32
- subtotalIva0: order.amountFiat,
33
- iva: 0,
34
- ice: 0,
35
- },
36
- contactDetails: {
37
- firstName: user.firstName,
38
- lastName: user.lastName,
39
- email: user.email,
40
- documentType: "CC",
41
- phoneNumber: user.phoneNumber,
42
- },
43
- orderDetails: {
44
- siteDomain: "riocrypto.com",
45
- shippingDetails: {
46
- name: `${user.firstName} ${user.lastName}`,
47
- phone: user.phoneNumber,
48
- address1: user.street1,
49
- address2: user.street2,
50
- city: user.city,
51
- region: user.state,
52
- country: user.country,
53
- zipcode: user.postalCode,
54
- },
55
- billingDetails: {
56
- name: `${user.firstName} ${user.lastName}`,
57
- phone: user.phoneNumber,
58
- address1: user.street1,
59
- address2: user.street2,
60
- city: user.city,
61
- region: user.state,
62
- country: user.country,
63
- zipcode: user.postalCode,
64
- },
65
- product: {
66
- id: order.id,
67
- title: order.crypto,
68
- price: order.amountFiat,
69
- sku: order.id,
70
- quantity: 1,
71
- },
72
- },
73
- };
74
- const response = yield (0, axios_1.default)({
75
- method: "post",
76
- url: `${this.baseUrl}/card/v1/charges`,
77
- headers: {
78
- "Content-Type": "application/json",
79
- "Private-Merchant-Id": this.privateMerchantId,
80
- "Accept-Encoding": "gzip,deflate,compress",
81
- },
82
- data: body,
83
- });
84
- const data = response.data;
85
- return data;
86
- });
87
- }
88
- createBankPaymentToken(order, user) {
89
- return __awaiter(this, void 0, void 0, function* () {
90
- const body = {
91
- amount: {
92
- subtotalIva: 0,
93
- subtotalIva0: order.amountFiat,
94
- iva: 0,
95
- },
96
- callbackUrl: "https://riocrypto.com",
97
- userType: user.type === common_1.UserType.Business ? 1 : 0,
98
- documentType: "CC",
99
- documentNumber: "123456789",
100
- paymentDescription: `Compra de ${order.crypto} en riocrypto.com`,
101
- email: user.email,
102
- currency: order.fiat,
103
- };
104
- const response = yield (0, axios_1.default)({
105
- method: "post",
106
- url: `${this.baseUrl}/transfer/v1/tokens`,
107
- headers: {
108
- "Content-Type": "application/json",
109
- "Private-Merchant-Id": this.privateMerchantId,
110
- "Accept-Encoding": "gzip,deflate,compress",
111
- },
112
- data: body,
113
- });
114
- const data = response.data;
115
- return data;
116
- });
117
- }
118
- createBankPayment(order, user, token) {
119
- return __awaiter(this, void 0, void 0, function* () {
120
- const body = {
121
- token,
122
- amount: {
123
- subtotalIva: 0,
124
- subtotalIva0: order.amountFiat,
125
- iva: 0,
126
- },
127
- contactDetails: {
128
- fullName: user.type === common_1.UserType.Business
129
- ? user.companyName
130
- : `${user.firstName} ${user.lastName}`,
131
- email: user.email,
132
- documentType: "CC",
133
- phoneNumber: user.phoneNumber,
134
- },
135
- };
136
- const response = yield (0, axios_1.default)({
137
- method: "post",
138
- url: `${this.baseUrl}/transfer/v1/init`,
139
- headers: {
140
- "Content-Type": "application/json",
141
- "Private-Merchant-Id": this.privateMerchantId,
142
- "Accept-Encoding": "gzip,deflate,compress",
143
- },
144
- data: body,
145
- });
146
- const data = response.data;
147
- return data;
148
- });
149
- }
150
- }
151
- const buildKushkiClient = () => __awaiter(void 0, void 0, void 0, function* () {
152
- const KUSHKI_PRIVATE_MERCHANT_ID = yield secret_manager_client_1.secretManagerClient.getSecretValue("KUSHKI_PRIVATE_MERCHANT_ID");
153
- if (!KUSHKI_PRIVATE_MERCHANT_ID) {
154
- throw new Error("Unable to get KUSHKI_PRIVATE_MERCHANT_ID");
155
- }
156
- const kushkiClient = new KushkiClient(KUSHKI_PRIVATE_MERCHANT_ID, process.env.KUSHKI_ENV);
157
- return kushkiClient;
158
- });
159
- exports.buildKushkiClient = buildKushkiClient;
@@ -1,21 +0,0 @@
1
- import { User } from "@riocrypto/common";
2
- declare class STPClient {
3
- private apiKey;
4
- private env;
5
- private baseUrl;
6
- constructor(apiKey: string, env: "production" | "sandbox");
7
- createCryptoListIndividualUser(user: User): Promise<{
8
- id: number;
9
- descripcion: string;
10
- }>;
11
- createCryptoListBusinessUser(user: User): Promise<{
12
- id: number;
13
- descripcion: string;
14
- }>;
15
- getCyptoListUsers(user: User): Promise<{
16
- id: number;
17
- descripcion: string;
18
- }>;
19
- }
20
- export declare const buildSTPClient: () => Promise<STPClient>;
21
- export {};
@@ -1,97 +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.buildSTPClient = void 0;
16
- const secret_manager_client_1 = require("./secret-manager-client");
17
- const axios_1 = __importDefault(require("axios"));
18
- const common_1 = require("@riocrypto/common");
19
- class STPClient {
20
- constructor(apiKey, env) {
21
- this.apiKey = apiKey;
22
- this.env = env;
23
- this.baseUrl =
24
- env === "production"
25
- ? "https://stpmex.com:7024"
26
- : "https://demo.stpmex.com:7024";
27
- }
28
- createCryptoListIndividualUser(user) {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- const { data } = yield axios_1.default.put(`${this.baseUrl}/speiws/rest/cuentaModule/fisicaCrypto`, {
31
- nombre: user.firstName.toLocaleUpperCase(),
32
- apellidoPaterno: user.lastName.toLocaleUpperCase(),
33
- apellidoMaterno: user.lastName.toLocaleUpperCase(),
34
- cuenta: "",
35
- empresa: "Rampa Blockchain SAPI",
36
- }, {
37
- headers: {
38
- Authorization: `Bearer ${this.apiKey}`,
39
- },
40
- });
41
- if (data.id !== 0) {
42
- throw new Error(data.descripcion);
43
- }
44
- return data;
45
- });
46
- }
47
- createCryptoListBusinessUser(user) {
48
- return __awaiter(this, void 0, void 0, function* () {
49
- const { data } = yield axios_1.default.put(`${this.baseUrl}/speiws/rest/cuentaModule/moralCrypto`, {
50
- nombre: user.companyName.toLocaleUpperCase(),
51
- cuenta: "",
52
- empresa: "Rampa Blockchain SAPI",
53
- fechaConstitucion: "2020-01-01",
54
- }, {
55
- headers: {
56
- Authorization: `Bearer ${this.apiKey}`,
57
- },
58
- });
59
- if (data.id !== 0) {
60
- throw new Error(data.descripcion);
61
- }
62
- return data;
63
- });
64
- }
65
- getCyptoListUsers(user) {
66
- return __awaiter(this, void 0, void 0, function* () {
67
- const { data } = yield axios_1.default.put(`${this.baseUrl}/speiws/rest/cuentaModule/moralCrypto`, {
68
- nombre: user.companyName.toLocaleUpperCase(),
69
- cuenta: "",
70
- empresa: "Rampa Blockchain SAPI",
71
- fechaConstitucion: "2020-01-01",
72
- }, {
73
- headers: {
74
- Authorization: `Bearer ${this.apiKey}`,
75
- },
76
- });
77
- if (data.id !== 0) {
78
- throw new Error(data.descripcion);
79
- }
80
- return data;
81
- });
82
- }
83
- }
84
- const buildSTPClient = () => __awaiter(void 0, void 0, void 0, function* () {
85
- // Retrieve secrets asynchronously
86
- const STP_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("STP_API_KEY");
87
- if (!STP_API_KEY) {
88
- throw new common_1.SecretManagerError();
89
- }
90
- const env = process.env.RIO_ENV === common_1.RioEnv.Production ||
91
- process.env.RIO_ENV === common_1.RioEnv.Staging ||
92
- process.env.RIO_ENV === common_1.RioEnv.Development
93
- ? "production"
94
- : "sandbox";
95
- return new STPClient(STP_API_KEY, env);
96
- });
97
- exports.buildSTPClient = buildSTPClient;