@cuenca-mx/cuenca-js 0.0.5-dev0 → 0.0.6-dev.0

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.cjs CHANGED
@@ -6,9 +6,10 @@ var axios = require('axios');
6
6
  var Buffer = require('buffer');
7
7
  var errors_index = require('./errors/index.cjs');
8
8
  var jwt_index = require('./jwt/index.cjs');
9
- var data = require('./data-6451748e.cjs');
10
- var identities = require('./identities-0a19fb53.cjs');
11
- var walletTransactionRequest = require('./walletTransactionRequest-267a5d18.cjs');
9
+ var data = require('./data-e5d6baf4.cjs');
10
+ var identities = require('./identities-e9f31da0.cjs');
11
+ var walletTransactionRequest = require('./walletTransactionRequest-3fa9e821.cjs');
12
+ require('module');
12
13
 
13
14
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
15
 
@@ -26,7 +27,7 @@ const isNode =
26
27
 
27
28
  const runtimeEnv = { isBrowser, isNode };
28
29
 
29
- const name="@cuenca-mx/cuenca-js";const version="0.0.5-dev0";const description="Cuenca client for JS";const main="./build/index.cjs";const module$1="./build/index.mjs";const browser="./build/umd/cuenca.umd.js";const files=["build/**/*"];const exports$1={".":{"import":"./build/index.mjs",require:"./build/index.cjs"},"./errors":{"import":"./build/errors/index.mjs",require:"./build/errors/index.cjs"},"./jwt":{"import":"./build/jwt/index.mjs",require:"./build/jwt/index.cjs"},"./requests":{"import":"./build/requests/index.mjs",require:"./build/requests/index.cjs"},"./types":{"import":"./build/types/index.mjs",require:"./build/types/index.cjs"}};const packageManager="yarn@3.0.2";const type="module";const repository={type:"git",url:"https://github.com/cuenca-mx/cuenca-js.git",directory:"packages/cuenca-js"};const keywords=["cuenca"];const license="MIT";const bugs={url:"https://github.com/cuenca-mx/cuenca-js/issues"};const homepage="https://cuenca.com";const scripts={build:"rm -rf build/ && yarn rollup --config",test:"yarn node --experimental-vm-modules $(yarn bin jest)",publish:"yarn build && yarn npm publish"};const devDependencies={"@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^13.1.1",jest:"^27.4.5",rollup:"^2.61.1","rollup-plugin-terser":"^7.0.2"};const dependencies={axios:"^0.24.0",buffer:"^6.0.3"};var pkg = {name:name,version:version,description:description,main:main,module:module$1,browser:browser,files:files,exports:exports$1,packageManager:packageManager,type:type,repository:repository,keywords:keywords,license:license,bugs:bugs,homepage:homepage,scripts:scripts,devDependencies:devDependencies,dependencies:dependencies};
30
+ const name="@cuenca-mx/cuenca-js";const version="0.0.6-dev.0";const description="Cuenca client for JS";const main="./build/index.cjs";const module$1="./build/index.mjs";const browser="./build/umd/cuenca.umd.js";const files=["build/**/*"];const exports$1={".":{"import":"./build/index.mjs",require:"./build/index.cjs"},"./errors":{"import":"./build/errors/index.mjs",require:"./build/errors/index.cjs"},"./jwt":{"import":"./build/jwt/index.mjs",require:"./build/jwt/index.cjs"},"./requests":{"import":"./build/requests/index.mjs",require:"./build/requests/index.cjs"},"./types":{"import":"./build/types/index.mjs",require:"./build/types/index.cjs"}};const packageManager="yarn@3.0.2";const type="module";const repository={type:"git",url:"https://github.com/cuenca-mx/cuenca-js.git",directory:"packages/cuenca-js"};const keywords=["cuenca"];const license="MIT";const bugs={url:"https://github.com/cuenca-mx/cuenca-js/issues"};const homepage="https://cuenca.com";const scripts={build:"rm -rf build/ && yarn rollup --config",test:"yarn node --experimental-vm-modules $(yarn bin jest)",publish:"yarn build && yarn npm publish"};const devDependencies={"@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^13.1.1",jest:"^27.4.5",rollup:"^2.61.1","rollup-plugin-terser":"^7.0.2"};const dependencies={axios:"^0.24.0",buffer:"^6.0.3","form-data":"^4.0.0"};var pkg = {name:name,version:version,description:description,main:main,module:module$1,browser:browser,files:files,exports:exports$1,packageManager:packageManager,type:type,repository:repository,keywords:keywords,license:license,bugs:bugs,homepage:homepage,scripts:scripts,devDependencies:devDependencies,dependencies:dependencies};
30
31
 
31
32
  class Client {
32
33
  constructor({
@@ -49,7 +50,7 @@ class Client {
49
50
  }
50
51
 
51
52
  get origin() {
52
- return `https://${this.phase.value}.cuenca.com`;
53
+ return `https://${this.phase.value}.arteria.xyz`;
53
54
  }
54
55
 
55
56
  get authHeader() {
@@ -133,8 +134,8 @@ class Client {
133
134
  return this.request({ endpoint, format, params });
134
135
  }
135
136
 
136
- async post({ endpoint, data }) {
137
- return this.request({ method: 'POST', endpoint, data });
137
+ async post({ endpoint, data, multipart }) {
138
+ return this.request({ method: 'POST', endpoint, data, multipart });
138
139
  }
139
140
 
140
141
  async patch({ endpoint, data }) {
@@ -150,12 +151,18 @@ class Client {
150
151
  data: data$1 = null,
151
152
  format = data.FileFormat.Json,
152
153
  method = 'GET',
154
+ multipart = false,
153
155
  params = null,
154
156
  }) {
155
- const headers = {
156
- 'Content-Type': 'application/json',
157
- Accept: `application/${format.value}`,
158
- };
157
+ let headers;
158
+ if (multipart) {
159
+ headers = data$1.getHeaders();
160
+ } else {
161
+ headers = {
162
+ 'Content-Type': 'application/json',
163
+ Accept: `application/${format.value}`,
164
+ };
165
+ }
159
166
 
160
167
  if (this.authHeader) {
161
168
  headers.Authorization = this.authHeader;
@@ -175,11 +182,10 @@ class Client {
175
182
  }
176
183
  headers['X-Cuenca-Token'] = this.jwtToken.token;
177
184
  }
178
-
179
185
  const headersInterceptor = this.addHeadersToRequest(headers);
180
186
 
181
187
  const modifiedData = data$1;
182
- if (modifiedData) {
188
+ if (modifiedData && !multipart) {
183
189
  Object.keys(modifiedData).forEach((k) => {
184
190
  if (modifiedData[k] instanceof Date) {
185
191
  modifiedData[k] = modifiedData[k].toISOString();
@@ -368,6 +374,163 @@ class BillPayment extends Transaction {
368
374
  });
369
375
  }
370
376
 
377
+ class BridgeAccount {
378
+ constructor({
379
+ id,
380
+ names,
381
+ firstSurname,
382
+ secondSurname,
383
+ dateOfBirth,
384
+ countryOfBirth,
385
+ rfc,
386
+ curp,
387
+ userId,
388
+ gender,
389
+ phoneNumber,
390
+ emailAddress,
391
+ clientClabe,
392
+ govtId,
393
+ proofOfAddress,
394
+ proofOfLife,
395
+ status,
396
+ }) {
397
+ this.id = id;
398
+ this.emailAddress = emailAddress;
399
+ this.clientClabe = clientClabe;
400
+ this.govtId = govtId;
401
+ this.names = names;
402
+ this.firstSurname = firstSurname;
403
+ this.secondSurname = secondSurname;
404
+ this.dateOfBirth = dateOfBirth;
405
+ this.countryOfBirth = countryOfBirth;
406
+ this.rfc = rfc;
407
+ this.curp = curp;
408
+ this.userId = userId;
409
+ this.gender = gender;
410
+ this.phoneNumber = phoneNumber;
411
+ this.addressProofs = proofOfAddress;
412
+ this.lifeProofs = proofOfLife;
413
+ this.status = data.enumValueFromString(data.BridgeAccountStatus, status);
414
+ }
415
+
416
+ static fromObject = ({ status, ...obj }) =>
417
+ new BridgeAccount({
418
+ id: obj.id,
419
+ clientClabe: obj.client_clabe,
420
+ names: obj.names,
421
+ firstSurname: obj.first_surname,
422
+ secondSurname: obj.second_surname,
423
+ dateOfBirth: obj.date_of_birth,
424
+ countryOfBirth: obj.country_of_birth,
425
+ rfc: obj.rfc,
426
+ curp: obj.curp,
427
+ userId: obj.user_id,
428
+ gender: obj.gender,
429
+ govtId: obj.govt_id,
430
+ emailAddress: obj.email_address,
431
+ phoneNumber: obj.phone_number,
432
+ proofOfAddress: obj.proof_of_address,
433
+ proofOfLife: obj.proof_of_life,
434
+ status,
435
+ });
436
+ }
437
+
438
+ class BridgeTransaction {
439
+ constructor({
440
+ id,
441
+ createdAt,
442
+ platformId,
443
+ type,
444
+ status,
445
+ accountId,
446
+ quoteId,
447
+ currency,
448
+ network,
449
+ sourceWallet,
450
+ destinationWallet,
451
+ bankAccountId,
452
+ cuencaId,
453
+ cuentaOrdenante,
454
+ cuentaBeneficiario,
455
+ nombreOrdenante,
456
+ claveRastreo,
457
+ rfcCurpOrdenante,
458
+ concepto,
459
+ referenciaNumerica,
460
+ signature,
461
+ trackingLink,
462
+ fromCurrency,
463
+ toCurrency,
464
+ fromAmount,
465
+ toAmount,
466
+ }) {
467
+ this.id = id;
468
+ this.createdAt = data.dateToUTC(createdAt);
469
+ this.platformId = platformId;
470
+ this.type = data.enumValueFromString(data.BridgeTransactionType, type);
471
+ this.status = data.enumValueFromString(data.TransactionStatus, status);
472
+ this.accountId = accountId;
473
+ this.quoteId = quoteId;
474
+ this.currency = data.enumValueFromString(data.Currency, currency);
475
+ this.network = data.enumValueFromString(data.Network, network);
476
+ this.sourceWallet = sourceWallet;
477
+ this.destinationWallet = destinationWallet;
478
+ this.bankAccountId = bankAccountId;
479
+ this.cuencaId = cuencaId;
480
+ this.cuentaOrdenante = cuentaOrdenante;
481
+ this.cuentaBeneficiario = cuentaBeneficiario;
482
+ this.nombreOrdenante = nombreOrdenante;
483
+ this.claveRastreo = claveRastreo;
484
+ this.rfcCurpOrdenante = rfcCurpOrdenante;
485
+ this.concepto = concepto;
486
+ this.referenciaNumerica = referenciaNumerica;
487
+ this.signature = signature;
488
+ this.trackingLink = trackingLink;
489
+ this.fromCurrency = data.enumValueFromString(data.Currency, fromCurrency);
490
+ this.toCurrency = data.enumValueFromString(data.Currency, toCurrency);
491
+ this.fromAmount = fromAmount;
492
+ this.toAmount = toAmount;
493
+ }
494
+
495
+ static fromObject = ({
496
+ type,
497
+ status,
498
+ currency,
499
+ network,
500
+ concepto,
501
+ signature,
502
+ ...obj
503
+ }) =>
504
+ new BridgeTransaction({
505
+ id: obj.id,
506
+ createdAt: obj.created_at,
507
+ platformId: obj.platform_id,
508
+ accountId: obj.account,
509
+ quoteId: obj.quote,
510
+ sourceWallet: obj.source_wallet,
511
+ destinationWallet: obj.destination_wallet,
512
+ bankAccountId: obj.bank_account,
513
+ cuencaId: obj.cuenca_id,
514
+ cuentaOrdenante: obj.cuenta_ordenante,
515
+ cuentaBeneficiario: obj.cuenta_beneficiario,
516
+ nombreOrdenante: obj.nombre_ordenante,
517
+ claveRastreo: obj.clave_rastreo,
518
+ rfcCurpOrdenante: obj.rfc_curp_ordenante,
519
+ referenciaNumerica: obj.referencia_numerica,
520
+ trackingLink: obj.tracking_link,
521
+ fromCurrency: obj.from_currency,
522
+ toCurrency: obj.to_currency,
523
+ fromAmount: obj.from_amount,
524
+ toAmount: obj.to_amount,
525
+ type,
526
+ status,
527
+ currency,
528
+ network,
529
+ concepto,
530
+ signature,
531
+ });
532
+ }
533
+
371
534
  class Card {
372
535
  constructor({
373
536
  createdAt,
@@ -628,6 +791,35 @@ class Deposit extends Transaction {
628
791
  });
629
792
  }
630
793
 
794
+ class File {
795
+ constructor({ extension, type, url, userId }) {
796
+ this.extension = extension;
797
+ this.type = data.enumValueFromString(data.KYCFileType, type);
798
+ this.url = url;
799
+ this.userId = userId;
800
+ }
801
+
802
+ static fromObject = ({ extension, type, url, ...obj }) =>
803
+ new File({ extension, type, url, userId: obj.user_id });
804
+ }
805
+
806
+ class KYCValidations {
807
+ constructor({ platformId, attemps, verificationId, filesUri }) {
808
+ this.attemps = attemps;
809
+ this.filesUri = filesUri;
810
+ this.platformId = platformId;
811
+ this.verificationId = verificationId;
812
+ }
813
+
814
+ static fromObject = ({ attemps, ...obj }) =>
815
+ new KYCValidations({
816
+ attemps,
817
+ filesUri: obj.files_uri,
818
+ platformId: obj.platform_id,
819
+ verificationId: obj.verification_id,
820
+ });
821
+ }
822
+
631
823
  class LoginToken {
632
824
  constructor({ id }) {
633
825
  this.id = id;
@@ -786,20 +978,25 @@ class User {
786
978
  address,
787
979
  blacklistValidationStatus,
788
980
  clabe,
981
+ countryOfBirth,
789
982
  createdAt,
790
983
  curp,
984
+ dateOfBirth,
791
985
  emailAddress,
792
986
  firstSurname,
987
+ gender,
793
988
  govtId,
794
989
  id,
795
990
  level,
796
991
  names,
992
+ nationality,
797
993
  phoneNumber,
798
994
  proofOfAddress,
799
995
  proofOfLife,
800
996
  requiredLevel,
801
997
  rfc,
802
998
  secondSurname,
999
+ stateOfBirth,
803
1000
  status,
804
1001
  termsOfService,
805
1002
  updatedAt,
@@ -811,20 +1008,25 @@ class User {
811
1008
  blacklistValidationStatus,
812
1009
  );
813
1010
  this.clabe = clabe;
1011
+ this.countryOfBirth = countryOfBirth;
814
1012
  this.createdAt = data.dateToUTC(createdAt);
815
1013
  this.curp = curp;
1014
+ this.dateOfBirth = dateOfBirth;
816
1015
  this.emailAddress = emailAddress;
817
1016
  this.firstSurname = firstSurname;
1017
+ this.gender = gender;
818
1018
  this.govstIds = govtId;
819
1019
  this.id = id;
820
1020
  this.level = level;
821
1021
  this.names = names;
1022
+ this.nationality = nationality;
822
1023
  this.phoneNumber = phoneNumber;
823
1024
  this.addressProofs = proofOfAddress;
824
1025
  this.lifeProofs = proofOfLife;
825
1026
  this.requiredLevel = requiredLevel;
826
1027
  this.rfc = rfc;
827
1028
  this.secondSurname = secondSurname;
1029
+ this.stateOfBirth = stateOfBirth;
828
1030
  this.status = data.enumValueFromString(data.UserStatus, status);
829
1031
  this.terms = termsOfService;
830
1032
  this.updatedAt = data.dateToUTC(updatedAt);
@@ -880,9 +1082,11 @@ class User {
880
1082
  address,
881
1083
  clabe,
882
1084
  curp,
1085
+ gender,
883
1086
  id,
884
1087
  level,
885
1088
  names,
1089
+ nationality,
886
1090
  rfc,
887
1091
  status,
888
1092
  ...obj
@@ -891,13 +1095,17 @@ class User {
891
1095
  address,
892
1096
  clabe,
893
1097
  curp,
1098
+ gender,
894
1099
  id,
895
1100
  level,
896
1101
  names,
1102
+ nationality,
897
1103
  rfc,
898
1104
  status,
899
1105
  blacklistValidationStatus: obj.blacklist_validation_status,
1106
+ countryOfBirth: obj.country_of_birth,
900
1107
  createdAt: obj.created_at,
1108
+ dateOfBirth: obj.date_of_birth,
901
1109
  emailAddress: obj.email_address,
902
1110
  firstSurname: obj.first_surname,
903
1111
  govtId: obj.govt_id,
@@ -906,6 +1114,7 @@ class User {
906
1114
  proofOfLife: obj.proof_of_life,
907
1115
  requiredLevel: obj.required_level,
908
1116
  secondSurname: obj.second_surname,
1117
+ stateOfBirth: obj.state_of_birth,
909
1118
  termsOfService: obj.terms_of_service,
910
1119
  updatedAt: obj.updated_at,
911
1120
  verificationId: obj.verification_id,
@@ -1077,12 +1286,16 @@ const getModelFromPath = (path, obj) => {
1077
1286
  arpc: () => Arpc.fromObject(obj),
1078
1287
  balance_entries: () => BalanceEntry.fromObject(obj),
1079
1288
  bill_payments: () => BillPayment.fromObject(obj),
1289
+ 'bridge/accounts': () => BridgeAccount.fromObject(obj),
1290
+ 'bridge/transactions': () => BridgeTransaction.fromObject(obj),
1080
1291
  cards: () => Card.fromObject(obj),
1081
1292
  card_activations: () => CardActivation.fromObject(obj),
1082
1293
  card_transactions: () => CardTransaction.fromObject(obj),
1083
1294
  card_validations: () => CardValidation.fromObject(obj),
1084
1295
  commissions: () => Commission.fromObject(obj),
1085
1296
  deposits: () => Deposit.fromObject(obj),
1297
+ files: () => File.fromObject(obj),
1298
+ kyc_validations: () => KYCValidations.fromObject(obj),
1086
1299
  login_tokens: () => LoginToken.fromObject(obj),
1087
1300
  savings: () => Saving.fromObject(obj),
1088
1301
  service_providers: () => ServiceProvider.fromObject(obj),
@@ -1148,6 +1361,19 @@ const Updateable = (SuperClass) =>
1148
1361
  }
1149
1362
  };
1150
1363
 
1364
+ const Uploadable = (SuperClass) =>
1365
+ class Uploadable extends SuperClass {
1366
+ async _upload(data) {
1367
+ const response = await this.client.post({
1368
+ endpoint: `/${this.path}`,
1369
+ data,
1370
+ multipart: true,
1371
+ });
1372
+ const model = getModelFromPath(this.path, response);
1373
+ return model;
1374
+ }
1375
+ };
1376
+
1151
1377
  const Deactivable = (SuperClass) =>
1152
1378
  class Deactivable extends SuperClass {
1153
1379
  async _deactivate(id, data) {
@@ -1163,10 +1389,14 @@ const Deactivable = (SuperClass) =>
1163
1389
  const Downlodable = (SuperClass) =>
1164
1390
  class Downlodable extends SuperClass {
1165
1391
  async _download(id, format) {
1392
+ const interceptor = this.client.addConfigToRequest({
1393
+ responseType: 'stream',
1394
+ });
1166
1395
  const byteString = await this.client.get({
1167
1396
  endpoint: `/${this.path}/${id}`,
1168
1397
  format,
1169
1398
  });
1399
+ interceptor.eject();
1170
1400
  return byteString;
1171
1401
  }
1172
1402
  };
@@ -1333,6 +1563,21 @@ class BillPaymentResource extends mix(Resource).with(Queryable, Retrievable) {
1333
1563
  }
1334
1564
  }
1335
1565
 
1566
+ class BridegAccountResource extends mix(Resource).with(Queryable, Retrievable) {
1567
+ constructor(client) {
1568
+ super('bridge/accounts', identities.BridgeAccountQuery, client);
1569
+ }
1570
+ }
1571
+
1572
+ class BridgeTransactionResource extends mix(Resource).with(
1573
+ Queryable,
1574
+ Retrievable,
1575
+ ) {
1576
+ constructor(client) {
1577
+ super('bridge/transactions', identities.BridgeTransactionQuery, client);
1578
+ }
1579
+ }
1580
+
1336
1581
  class CardActivationResource extends mix(Resource).with(Creatable) {
1337
1582
  constructor(client) {
1338
1583
  super('card_activations', Object, client);
@@ -1460,6 +1705,39 @@ class DepositResource extends mix(Resource).with(Queryable, Retrievable) {
1460
1705
  }
1461
1706
  }
1462
1707
 
1708
+ class FileResource extends mix(Resource).with(Downlodable, Uploadable) {
1709
+ constructor(client) {
1710
+ super('files', Object, client);
1711
+ }
1712
+
1713
+ async download(id) {
1714
+ const byteString = await this._download(id, data.FileFormat.Any);
1715
+ return byteString;
1716
+ }
1717
+
1718
+ async upload({ ...req }) {
1719
+ const request = new walletTransactionRequest.UploadRequest(req);
1720
+ const fileUpload = await this._upload(request.toFormData());
1721
+ return fileUpload;
1722
+ }
1723
+ }
1724
+
1725
+ class KYCValidationsResource extends mix(Resource).with(
1726
+ Creatable,
1727
+ Retrievable,
1728
+ Queryable,
1729
+ ) {
1730
+ constructor(client) {
1731
+ super('kyc_validations', Object, client);
1732
+ }
1733
+
1734
+ async create(userId = 'me') {
1735
+ const request = new walletTransactionRequest.KYCValidationsRequest(userId);
1736
+ const kycValidation = await this._create(request.toObject());
1737
+ return kycValidation;
1738
+ }
1739
+ }
1740
+
1463
1741
  class LoginTokenResource extends mix(Resource).with(Creatable) {
1464
1742
  constructor(client) {
1465
1743
  super('login_tokens', Object, client);
@@ -1746,12 +2024,16 @@ class Cuenca {
1746
2024
  this.apiKeys = new ApiKeyResource(client);
1747
2025
  this.balanceEntries = new BalanceEntryResource(client);
1748
2026
  this.billPayments = new BillPaymentResource(client);
2027
+ this.bridgeAccounts = new BridegAccountResource(client);
2028
+ this.bridgeTransactions = new BridgeTransactionResource(client);
1749
2029
  this.cardActivations = new CardActivationResource(client);
1750
2030
  this.cards = new CardResource(client);
1751
2031
  this.cardTransactions = new CardTransactionResource(client);
1752
2032
  this.cardValidations = new CardValidationResource(client);
1753
2033
  this.commissions = new CommissionResource(client);
1754
2034
  this.deposits = new DepositResource(client);
2035
+ this.files = new FileResource(client);
2036
+ this.kycValidations = new KYCValidationsResource(client);
1755
2037
  this.loginTokens = new LoginTokenResource(client);
1756
2038
  this.savings = new SavingResource(client);
1757
2039
  this.serviceProviders = new ServiceProviderResource(client);