@cuenca-mx/cuenca-js 0.0.1-dev.9 → 0.0.2-dev.1

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.mjs CHANGED
@@ -1,19 +1,38 @@
1
1
  import axios from 'axios';
2
+ import Buffer from 'buffer';
2
3
  import { CuencaResponseException, CuencaException, NoResultFound, MultipleResultsFound, InvalidPassword } from './errors/index.mjs';
3
- export { CuencaException, CuencaResponseException, InvalidPassword, MalformedJwtToken, MultipleResultsFound, NoResultFound, ValidationError } from './errors/index.mjs';
4
4
  import { Jwt } from './jwt/index.mjs';
5
- export { Jwt } from './jwt/index.mjs';
6
- import { P as Phase, F as FileFormat, E as EntryType, T as TransactionStatus, C as CardIssuer, a as CardStatus, b as CardType, c as CardFundingType, d as CardErrorType, e as CardTransactionType, f as CommissionType, D as DepositNetwork, S as SavingCategory, g as ServiceProviderCategory, h as TransferNetwork, W as WalletTransactionType, A as AccountQuery, i as ApiKeyQuery, B as BalanceEntryQuery, j as BillPaymentQuery, k as CardsQuery, l as CardTransactionQuery, Q as QueryParams, m as DepositQuery, n as WalletQuery, o as StatementQuery, p as TransferQuery, q as WalletTransactionQuery } from './queries-f146b91b.js';
7
- export { A as AccountQuery, i as ApiKeyQuery, B as BalanceEntryQuery, j as BillPaymentQuery, d as CardErrorType, c as CardFundingType, C as CardIssuer, a as CardStatus, l as CardTransactionQuery, e as CardTransactionType, b as CardType, k as CardsQuery, f as CommissionType, D as DepositNetwork, m as DepositQuery, E as EntryType, F as FileFormat, s as PageSize, P as Phase, Q as QueryParams, S as SavingCategory, g as ServiceProviderCategory, o as StatementQuery, r as TrackDataMethod, T as TransactionStatus, h as TransferNetwork, p as TransferQuery, n as WalletQuery, q as WalletTransactionQuery, W as WalletTransactionType } from './queries-f146b91b.js';
8
- import { d as dateToUTC, e as enumValueFromString } from './data-7d3d5fcc.js';
9
- import { A as ApiKeyUpdateRequest, a as ArpcRequest, C as CardActivationRequest, b as CardRequest, c as CardUpdateRequest, d as CardValidationRequest, S as SavingRequest, T as TransferRequest, U as UserCredentialRequest, e as UserCredentialUpdateRequest, f as UserLoginRequest, W as WalletTransactionRequest } from './walletTransactionRequest-bbfb87bd.js';
5
+ import { P as Phase, F as FileFormat, d as dateToUTC, e as enumValueFromString, E as EntryType, T as TransactionStatus, C as CardFundingType, a as CardIssuer, b as CardStatus, c as CardType, f as CardErrorType, g as CardTransactionType, h as CommissionType, D as DepositNetwork, S as SavingCategory, i as ServiceProviderCategory, j as TransferNetwork, U as UserStatus, V as VerificationType, W as WalletTransactionType } from './data-69952249.mjs';
6
+ import { K as KYCFile, T as TOSAgreements, A as AccountQuery, a as ApiKeyQuery, B as BalanceEntryQuery, b as BillPaymentQuery, C as CardsQuery, c as CardTransactionQuery, Q as QueryParams, D as DepositQuery, W as WalletQuery, S as StatementQuery, d as TransferQuery, U as UserQuery, e as WalletTransactionQuery } from './identities-5e48f342.mjs';
7
+ import { A as ApiKeyUpdateRequest, a as ArpcRequest, C as CardActivationRequest, b as CardRequest, c as CardUpdateRequest, d as CardValidationRequest, I as IdentitiesUploadRequest, S as SavingRequest, T as TransferRequest, U as UserCredentialRequest, e as UserCredentialUpdateRequest, f as UserLoginRequest, g as UserUpdateRequest, V as VerificationRequest, h as VerificationAttemptRequest, W as WalletTransactionRequest } from './walletTransactionRequest-f515485a.mjs';
8
+
9
+ /* global window */
10
+
11
+ const isBrowser =
12
+ typeof window !== 'undefined' && typeof window.document !== 'undefined';
13
+
14
+ const isNode =
15
+ typeof process !== 'undefined' &&
16
+ Object.prototype.toString.call(process) === '[object process]';
17
+
18
+ const runtimeEnv = { isBrowser, isNode };
19
+
20
+ const name="@cuenca-mx/cuenca-js";const version="0.0.2-dev.1";const description="Cuenca client for JS";const main="./build/index.cjs";const module="./build/index.mjs";const browser="./build/umd/cuenca.umd.js";const files=["build/**/*"];const exports={".":{"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,browser:browser,files:files,exports:exports,packageManager:packageManager,type:type,repository:repository,keywords:keywords,license:license,bugs:bugs,homepage:homepage,scripts:scripts,devDependencies:devDependencies,dependencies:dependencies};
10
21
 
11
22
  class Client {
12
- constructor({ apiKey, apiSecret, phase = Phase.Sandbox } = {}) {
23
+ constructor({
24
+ apiKey,
25
+ apiSecret,
26
+ language = 'en',
27
+ phase = Phase.Sandbox,
28
+ } = {}) {
13
29
  this.phase = phase;
14
30
  this.basicAuth = { apiKey, apiSecret };
15
31
  this.jwtToken = null;
16
- this._session = axios.create();
32
+ this._session = axios.create({
33
+ headers: { 'Accept-Language': language },
34
+ timeout: 45000,
35
+ });
17
36
  }
18
37
 
19
38
  get session() {
@@ -27,8 +46,9 @@ class Client {
27
46
  get authHeader() {
28
47
  const { apiKey, apiSecret } = this.basicAuth;
29
48
  if (!apiKey || !apiSecret) return '';
30
- return `Basic ${Buffer.from(
31
- Buffer.from(`${apiKey}:${apiSecret}`).toString('utf-8'),
49
+ return `Basic ${Buffer.Buffer.from(
50
+ `${apiKey}:${apiSecret}`,
51
+ 'utf-8',
32
52
  ).toString('base64')}`;
33
53
  }
34
54
 
@@ -74,7 +94,14 @@ class Client {
74
94
  };
75
95
  }
76
96
 
77
- async configure({ apiKey, apiSecret, loginToken, phase, useJwt = false }) {
97
+ async configure({
98
+ apiKey,
99
+ apiSecret,
100
+ loginToken,
101
+ phase,
102
+ sessionId,
103
+ useJwt = false,
104
+ }) {
78
105
  this.basicAuth = {
79
106
  apiKey: apiKey || this.basicAuth.apiKey,
80
107
  apiSecret: apiSecret || this.basicAuth.apiSecret,
@@ -87,14 +114,18 @@ class Client {
87
114
  if (loginToken) {
88
115
  this.addHeadersToRequest({ 'X-Cuenca-LoginToken': loginToken });
89
116
  }
117
+
118
+ if (sessionId) {
119
+ this.addHeadersToRequest({ 'X-Cuenca-SessionId': sessionId });
120
+ }
90
121
  }
91
122
 
92
123
  async get({ endpoint, format, params }) {
93
124
  return this.request({ endpoint, format, params });
94
125
  }
95
126
 
96
- async post({ endpoint, data }) {
97
- return this.request({ method: 'POST', endpoint, data });
127
+ async post({ endpoint, data, multipart }) {
128
+ return this.request({ method: 'POST', endpoint, data, multipart });
98
129
  }
99
130
 
100
131
  async patch({ endpoint, data }) {
@@ -110,14 +141,32 @@ class Client {
110
141
  data = null,
111
142
  format = FileFormat.Json,
112
143
  method = 'GET',
144
+ multipart = false,
113
145
  params = null,
114
146
  }) {
115
- const headers = {
116
- Authorization: this.authHeader,
117
- 'X-User-Agent': `cuenca-js/0.0.1`, // TODO: Change for client version
118
- 'Content-Type': 'application/json',
119
- Accept: `application/${format.value}`,
120
- };
147
+ console.log('multipart :', multipart);
148
+ console.log('endPoint', endpoint);
149
+ let headers;
150
+ if (multipart) {
151
+ headers = data.getHeaders();
152
+ } else {
153
+ headers = {
154
+ 'Content-Type': 'application/json',
155
+ Accept: `application/${format.value}`,
156
+ };
157
+ }
158
+
159
+ if (this.authHeader) {
160
+ headers.Authorization = this.authHeader;
161
+ }
162
+
163
+ if (runtimeEnv.isNode) {
164
+ headers['User-Agent'] = `cuenca-js/${pkg.version}`;
165
+ } else if (runtimeEnv.isBrowser) {
166
+ // Cannot set User-Agent header on browsers
167
+ // https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name
168
+ headers['X-User-Agent'] = `cuenca-js/${pkg.version}`;
169
+ }
121
170
 
122
171
  if (this.jwtToken) {
123
172
  if (this.jwtToken.isExpired) {
@@ -125,8 +174,9 @@ class Client {
125
174
  }
126
175
  headers['X-Cuenca-Token'] = this.jwtToken.token;
127
176
  }
128
-
177
+ console.log('headers :', headers);
129
178
  const headersInterceptor = this.addHeadersToRequest(headers);
179
+ console.log('headersInterceptor :', headersInterceptor);
130
180
 
131
181
  const modifiedData = data;
132
182
  if (modifiedData) {
@@ -137,6 +187,8 @@ class Client {
137
187
  });
138
188
  }
139
189
 
190
+ console.log('modifiedData :', modifiedData);
191
+
140
192
  const configInterceptor = this.addConfigToRequest({
141
193
  method,
142
194
  params,
@@ -293,7 +345,13 @@ class BillPayment extends Transaction {
293
345
  status,
294
346
  userId,
295
347
  }) {
296
- super({ amount, createdAt, descriptor, status, userId });
348
+ super({
349
+ amount,
350
+ createdAt,
351
+ descriptor,
352
+ status,
353
+ userId,
354
+ });
297
355
  this.accountNumber = accountNumber;
298
356
  this.id = id;
299
357
  this.providerUri = providerUri;
@@ -407,7 +465,13 @@ class CardTransaction extends Transaction {
407
465
  type,
408
466
  userId,
409
467
  }) {
410
- super({ amount, createdAt, descriptor, status, userId });
468
+ super({
469
+ amount,
470
+ createdAt,
471
+ descriptor,
472
+ status,
473
+ userId,
474
+ });
411
475
  this.cardErrorType = enumValueFromString(CardErrorType, cardErrorType);
412
476
  this.cardLastFour = cardLastFour;
413
477
  this.cardType = enumValueFromString(CardType, cardType);
@@ -504,7 +568,13 @@ class Commission extends Transaction {
504
568
  type,
505
569
  userId,
506
570
  }) {
507
- super({ amount, createdAt, descriptor, status, userId });
571
+ super({
572
+ amount,
573
+ createdAt,
574
+ descriptor,
575
+ status,
576
+ userId,
577
+ });
508
578
  this.relatedTransactionUri = relatedTransactionUri;
509
579
  this.type = enumValueFromString(CommissionType, type);
510
580
  }
@@ -533,7 +603,13 @@ class Deposit extends Transaction {
533
603
  trackingKey,
534
604
  userId,
535
605
  }) {
536
- super({ amount, createdAt, descriptor, status, userId });
606
+ super({
607
+ amount,
608
+ createdAt,
609
+ descriptor,
610
+ status,
611
+ userId,
612
+ });
537
613
  this.id = id;
538
614
  this.network = enumValueFromString(DepositNetwork, network);
539
615
  this.sourceUri = sourceUri;
@@ -554,6 +630,96 @@ class Deposit extends Transaction {
554
630
  });
555
631
  }
556
632
 
633
+ class Identities {
634
+ constructor({
635
+ address,
636
+ blacklistValidationStatus,
637
+ countryOfBirth,
638
+ createdAt,
639
+ curp,
640
+ dateOfBirth,
641
+ extension,
642
+ firstSurname,
643
+ gender,
644
+ govId,
645
+ id,
646
+ names,
647
+ nationality,
648
+ proofOfAddress,
649
+ proofOfLife,
650
+ rfc,
651
+ rfcDocument,
652
+ rfcFile,
653
+ secondSurname,
654
+ stateOfBirth,
655
+ status,
656
+ tosAgreement,
657
+ userId,
658
+ }) {
659
+ this.address = address;
660
+ this.blacklistValidationStatus = blacklistValidationStatus;
661
+ this.countryOfBirth = countryOfBirth;
662
+ this.createdAt = createdAt;
663
+ this.curp = curp;
664
+ this.dateOfBirth = dateOfBirth;
665
+ this.extension = extension;
666
+ this.firstSurname = firstSurname;
667
+ this.gender = gender;
668
+ this.govId = govId;
669
+ this.id = id;
670
+ this.names = names;
671
+ this.nationality = nationality;
672
+ this.proofOfAddress = proofOfAddress;
673
+ this.proofOfLife = proofOfLife;
674
+ this.rfc = rfc;
675
+ this.rfcDocument = rfcDocument;
676
+ this.rfcFile = rfcFile;
677
+ this.secondSurname = secondSurname;
678
+ this.stateOfBirth = stateOfBirth;
679
+ this.status = status;
680
+ this.tosAgreement = tosAgreement;
681
+ this.userId = userId;
682
+ }
683
+
684
+ static fromObject = ({
685
+ address,
686
+ curp,
687
+ extension,
688
+ gender,
689
+ id,
690
+ names,
691
+ nationality,
692
+ rfc,
693
+ status,
694
+ ...obj
695
+ }) =>
696
+ new Identities({
697
+ address,
698
+ curp,
699
+ extension,
700
+ gender,
701
+ id,
702
+ names,
703
+ nationality,
704
+ rfc,
705
+ status,
706
+ blacklistValidationStatus: obj.blacklist_validation_status,
707
+ countryOfBirth: obj.country_of_birth,
708
+ createdAt: obj.created_at,
709
+ dateOfBirth: obj.date_of_birth,
710
+ firstSurname: obj.first_surname,
711
+ govId: obj.gov_id,
712
+ proofOfAddress: obj.proof_of_address,
713
+ proofOfLife: obj.proof_of_life,
714
+ rfcDocument: obj.rfc_document,
715
+ rfcFile: obj.rfc_file,
716
+ secondSurname: obj.second_surname,
717
+ stateOfBirth: obj.state_of_birth,
718
+ tosAgreement: obj.tos_agreement,
719
+ userId: obj.user_id,
720
+ });
721
+ }
722
+
557
723
  class LoginToken {
558
724
  constructor({ id }) {
559
725
  this.id = id;
@@ -586,7 +752,14 @@ class Saving extends Wallet {
586
752
  userId,
587
753
  updatedAt,
588
754
  }) {
589
- super({ balance, createdAt, deactivatedAt, id, userId, updatedAt });
755
+ super({
756
+ balance,
757
+ createdAt,
758
+ deactivatedAt,
759
+ id,
760
+ userId,
761
+ updatedAt,
762
+ });
590
763
  this.category = enumValueFromString(SavingCategory, category);
591
764
  this.goalAmount = goalAmount;
592
765
  this.goalDate = dateToUTC(goalDate);
@@ -665,7 +838,13 @@ class Transfer extends Transaction {
665
838
  updatedAt,
666
839
  userId,
667
840
  }) {
668
- super({ amount, createdAt, descriptor, status, userId });
841
+ super({
842
+ amount,
843
+ createdAt,
844
+ descriptor,
845
+ status,
846
+ userId,
847
+ });
669
848
  this.accountNumber = accountNumber;
670
849
  this.destinationUri = destinationUri;
671
850
  this.id = id;
@@ -694,6 +873,82 @@ class Transfer extends Transaction {
694
873
  });
695
874
  }
696
875
 
876
+ class User {
877
+ constructor({
878
+ emailAddress,
879
+ govtId,
880
+ identityUri,
881
+ level,
882
+ phoneNumber,
883
+ proofOfAddress,
884
+ proofOfLife,
885
+ status,
886
+ termsOfService,
887
+ verificationId,
888
+ }) {
889
+ this.emailAddress = emailAddress;
890
+ this.govstIds = govtId;
891
+ this.identityUri = identityUri;
892
+ this.level = level;
893
+ this.phoneNumber = phoneNumber;
894
+ this.addressProofs = proofOfAddress;
895
+ this.lifeProofs = proofOfLife;
896
+ this.status = enumValueFromString(UserStatus, status);
897
+ this.terms = termsOfService;
898
+ this.verificationId = verificationId;
899
+ }
900
+
901
+ get proofOfAddress() {
902
+ return this._proofOfAddress;
903
+ }
904
+
905
+ set addressProofs(value) {
906
+ if (!value) return;
907
+ this._proofOfAddress = KYCFile.fromObject(value);
908
+ }
909
+
910
+ get proofOfLife() {
911
+ return this._proofOfLife;
912
+ }
913
+
914
+ set lifeProofs(value) {
915
+ if (!value) return;
916
+ this._proofOfLife = KYCFile.fromObject(value);
917
+ }
918
+
919
+ get govtId() {
920
+ return this._govtId;
921
+ }
922
+
923
+ set govstIds(value) {
924
+ if (!value) return;
925
+ this._govtId = KYCFile.fromObject(value);
926
+ }
927
+
928
+ get termsOfService() {
929
+ return this._termsOfService;
930
+ }
931
+
932
+ set terms(value) {
933
+ if (!value) return;
934
+ this._termsOfService = TOSAgreements.fromObject(value);
935
+ }
936
+
937
+ static fromObject = ({ level, status, ...obj }) =>
938
+ new User({
939
+ level,
940
+ status,
941
+ govtId: obj.govt_id,
942
+ identityUri: obj.identity_uri,
943
+ emailAddress: obj.email_address,
944
+ phoneNumber: obj.phone_number,
945
+ proofOfAddress: obj.proof_of_address,
946
+ proofOfLife: obj.proof_of_life,
947
+ termsOfService: obj.terms_of_service,
948
+ verificationId: obj.verification_id,
949
+ });
950
+ }
951
+
697
952
  class UserCredential {
698
953
  constructor({ createdAt, id, isActive, updatedAt }) {
699
954
  this.createdAt = dateToUTC(createdAt);
@@ -726,6 +981,27 @@ class UserLogin {
726
981
  });
727
982
  }
728
983
 
984
+ class Verification {
985
+ constructor({ createdAt, id, platformId, recipient, type, updatedAt }) {
986
+ this.createdAt = dateToUTC(createdAt);
987
+ this.id = id;
988
+ this.platformId = platformId;
989
+ this.recipient = recipient;
990
+ this.type = enumValueFromString(VerificationType, type);
991
+ this.updatedAt = dateToUTC(updatedAt);
992
+ }
993
+
994
+ static fromObject = ({ id, recipient, type, ...obj }) =>
995
+ new Verification({
996
+ id,
997
+ recipient,
998
+ type,
999
+ createdAt: obj.created_at,
1000
+ platformId: obj.platform_id,
1001
+ updatedAt: obj.updated_at,
1002
+ });
1003
+ }
1004
+
729
1005
  class WalletTransaction extends Transaction {
730
1006
  constructor({
731
1007
  amount,
@@ -737,7 +1013,13 @@ class WalletTransaction extends Transaction {
737
1013
  userId,
738
1014
  walletUri,
739
1015
  }) {
740
- super({ amount, createdAt, descriptor, status, userId });
1016
+ super({
1017
+ amount,
1018
+ createdAt,
1019
+ descriptor,
1020
+ status,
1021
+ userId,
1022
+ });
741
1023
  this.id = id;
742
1024
  this.transactionType = enumValueFromString(
743
1025
  WalletTransactionType,
@@ -776,7 +1058,13 @@ class WhatsAppTransfer extends Transaction {
776
1058
  updatedAt,
777
1059
  userId,
778
1060
  }) {
779
- super({ amount, createdAt, descriptor, status, userId });
1061
+ super({
1062
+ amount,
1063
+ createdAt,
1064
+ descriptor,
1065
+ status,
1066
+ userId,
1067
+ });
780
1068
  this.claimUrl = claimUrl;
781
1069
  this.destinationUri = destinationUri;
782
1070
  this.id = id;
@@ -832,13 +1120,16 @@ const getModelFromPath = (path, obj) => {
832
1120
  card_validations: () => CardValidation.fromObject(obj),
833
1121
  commissions: () => Commission.fromObject(obj),
834
1122
  deposits: () => Deposit.fromObject(obj),
1123
+ identities: () => Identities.fromObject(obj),
835
1124
  login_tokens: () => LoginToken.fromObject(obj),
836
1125
  savings: () => Saving.fromObject(obj),
837
1126
  service_providers: () => ServiceProvider.fromObject(obj),
838
1127
  statements: () => Statement.fromObject(obj),
839
1128
  transfers: () => Transfer.fromObject(obj),
1129
+ users: () => User.fromObject(obj),
840
1130
  user_credentials: () => UserCredential.fromObject(obj),
841
1131
  user_logins: () => UserLogin.fromObject(obj),
1132
+ verifications: () => Verification.fromObject(obj),
842
1133
  wallet_transactions: () => WalletTransaction.fromObject(obj),
843
1134
  whatsapp_transfers: () => WhatsAppTransfer.fromObject(obj),
844
1135
  };
@@ -895,6 +1186,19 @@ const Updateable = (SuperClass) =>
895
1186
  }
896
1187
  };
897
1188
 
1189
+ const Uploadable = (SuperClass) =>
1190
+ class Uploadable extends SuperClass {
1191
+ async _upload(id, data) {
1192
+ const response = await this.client.post({
1193
+ endpoint: `/${this.path}`,
1194
+ data,
1195
+ multipart: true,
1196
+ });
1197
+ const model = getModelFromPath(this.path, response);
1198
+ return model;
1199
+ }
1200
+ };
1201
+
898
1202
  const Deactivable = (SuperClass) =>
899
1203
  class Deactivable extends SuperClass {
900
1204
  async _deactivate(id, data) {
@@ -1207,6 +1511,19 @@ class DepositResource extends mix(Resource).with(Queryable, Retrievable) {
1207
1511
  }
1208
1512
  }
1209
1513
 
1514
+ class IdentitiesResource extends mix(Resource).with(Uploadable) {
1515
+ constructor(client) {
1516
+ super('identities', Object, client);
1517
+ }
1518
+
1519
+ async upload({ extension, id, rfcFile, userId = 'me' }) {
1520
+ const request = new IdentitiesUploadRequest({ extension, rfcFile, userId });
1521
+ const identities = await this._upload(id, request.toFormData());
1522
+ // const identities = await this._update(identityId, request.toObject());
1523
+ return identities;
1524
+ }
1525
+ }
1526
+
1210
1527
  class LoginTokenResource extends mix(Resource).with(Creatable) {
1211
1528
  constructor(client) {
1212
1529
  super('login_tokens', Object, client);
@@ -1398,6 +1715,40 @@ class UserLoginResource extends mix(Resource).with(Creatable, Deactivable) {
1398
1715
  }
1399
1716
  }
1400
1717
 
1718
+ class UserResourse extends mix(Resource).with(
1719
+ Queryable,
1720
+ Updateable,
1721
+ Retrievable,
1722
+ ) {
1723
+ constructor(client) {
1724
+ super('users', UserQuery, client);
1725
+ }
1726
+
1727
+ async update({ userId = 'me', ...req }) {
1728
+ const request = new UserUpdateRequest(req);
1729
+ const user = await this._update(userId, request.toCleanObject());
1730
+ return user;
1731
+ }
1732
+ }
1733
+
1734
+ class VerificationResourse extends mix(Resource).with(Creatable, Updateable) {
1735
+ constructor(client) {
1736
+ super('verifications', Object, client);
1737
+ }
1738
+
1739
+ async create({ platformId, recipient, type }) {
1740
+ const request = new VerificationRequest({ platformId, recipient, type });
1741
+ const verification = await this._create(request.toObject());
1742
+ return verification;
1743
+ }
1744
+
1745
+ async update({ code, id }) {
1746
+ const request = new VerificationAttemptRequest({ code });
1747
+ const verification = await this._update(id, request.toObject());
1748
+ return verification;
1749
+ }
1750
+ }
1751
+
1401
1752
  class WalletTransactionsResource extends mix(Resource).with(
1402
1753
  Creatable,
1403
1754
  Queryable,
@@ -1444,8 +1795,13 @@ class WhatsAppTransferResource extends mix(Resource).with(
1444
1795
  }
1445
1796
 
1446
1797
  class Cuenca {
1447
- constructor(apiKey, apiSecret, phase = Phase.Sandbox) {
1448
- this.client = new Client({ apiKey, apiSecret, phase });
1798
+ constructor({
1799
+ apiKey,
1800
+ apiSecret,
1801
+ language = 'en',
1802
+ phase = Phase.Sandbox,
1803
+ } = {}) {
1804
+ this.client = new Client({ apiKey, apiSecret, language, phase });
1449
1805
  this.withClient(this.client);
1450
1806
  }
1451
1807
 
@@ -1460,6 +1816,7 @@ class Cuenca {
1460
1816
  this.cardValidations = new CardValidationResource(client);
1461
1817
  this.commissions = new CommissionResource(client);
1462
1818
  this.deposits = new DepositResource(client);
1819
+ this.identities = new IdentitiesResource(client);
1463
1820
  this.loginTokens = new LoginTokenResource(client);
1464
1821
  this.savings = new SavingResource(client);
1465
1822
  this.serviceProviders = new ServiceProviderResource(client);
@@ -1467,6 +1824,8 @@ class Cuenca {
1467
1824
  this.transfers = new TransferResource(client);
1468
1825
  this.userCredentials = new UserCredentialResource(client);
1469
1826
  this.userLogins = new UserLoginResource(client);
1827
+ this.users = new UserResourse(client);
1828
+ this.verifications = new VerificationResourse(client);
1470
1829
  this.walletTransactions = new WalletTransactionsResource(client);
1471
1830
  this.whatsAppTransfers = new WhatsAppTransferResource(client);
1472
1831
  }
@@ -2,7 +2,12 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var errors_index = require('../errors/index.js');
5
+ var Buffer = require('buffer');
6
+ var errors_index = require('../errors/index.cjs');
7
+
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
+
10
+ var Buffer__default = /*#__PURE__*/_interopDefaultLegacy(Buffer);
6
11
 
7
12
  class Jwt {
8
13
  constructor(expiresAt, token) {
@@ -20,7 +25,7 @@ class Jwt {
20
25
  try {
21
26
  const [, payloadEncoded] = token.split('.');
22
27
  payload = JSON.parse(
23
- Buffer.from(`${payloadEncoded}==`, 'base64').toString(),
28
+ Buffer__default["default"].Buffer.from(`${payloadEncoded}==`, 'base64').toString(),
24
29
  );
25
30
  } catch (error) {
26
31
  throw new errors_index.MalformedJwtToken();
@@ -1,3 +1,4 @@
1
+ import Buffer from 'buffer';
1
2
  import { MalformedJwtToken } from '../errors/index.mjs';
2
3
 
3
4
  class Jwt {
@@ -16,7 +17,7 @@ class Jwt {
16
17
  try {
17
18
  const [, payloadEncoded] = token.split('.');
18
19
  payload = JSON.parse(
19
- Buffer.from(`${payloadEncoded}==`, 'base64').toString(),
20
+ Buffer.Buffer.from(`${payloadEncoded}==`, 'base64').toString(),
20
21
  );
21
22
  } catch (error) {
22
23
  throw new MalformedJwtToken();
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var walletTransactionRequest = require('../walletTransactionRequest-b588cc52.js');
6
- require('../errors/index.js');
7
- require('../data-c53f1052.js');
5
+ var walletTransactionRequest = require('../walletTransactionRequest-31f14989.cjs');
6
+ require('../errors/index.cjs');
7
+ require('../data-efb53250.cjs');
8
8
 
9
9
 
10
10
 
@@ -14,9 +14,13 @@ exports.CardActivationRequest = walletTransactionRequest.CardActivationRequest;
14
14
  exports.CardRequest = walletTransactionRequest.CardRequest;
15
15
  exports.CardUpdateRequest = walletTransactionRequest.CardUpdateRequest;
16
16
  exports.CardValidationRequest = walletTransactionRequest.CardValidationRequest;
17
+ exports.IdentitiesUploadRequest = walletTransactionRequest.IdentitiesUploadRequest;
17
18
  exports.SavingRequest = walletTransactionRequest.SavingRequest;
18
19
  exports.TransferRequest = walletTransactionRequest.TransferRequest;
19
20
  exports.UserCredentialRequest = walletTransactionRequest.UserCredentialRequest;
20
21
  exports.UserCredentialUpdateRequest = walletTransactionRequest.UserCredentialUpdateRequest;
21
22
  exports.UserLoginRequest = walletTransactionRequest.UserLoginRequest;
23
+ exports.UserUpdateRequest = walletTransactionRequest.UserUpdateRequest;
24
+ exports.VerificationAttemptRequest = walletTransactionRequest.VerificationAttemptRequest;
25
+ exports.VerificationRequest = walletTransactionRequest.VerificationRequest;
22
26
  exports.WalletTransactionRequest = walletTransactionRequest.WalletTransactionRequest;
@@ -1,3 +1,3 @@
1
- export { A as ApiKeyUpdateRequest, a as ArpcRequest, C as CardActivationRequest, b as CardRequest, c as CardUpdateRequest, d as CardValidationRequest, S as SavingRequest, T as TransferRequest, U as UserCredentialRequest, e as UserCredentialUpdateRequest, f as UserLoginRequest, W as WalletTransactionRequest } from '../walletTransactionRequest-bbfb87bd.js';
1
+ export { A as ApiKeyUpdateRequest, a as ArpcRequest, C as CardActivationRequest, b as CardRequest, c as CardUpdateRequest, d as CardValidationRequest, I as IdentitiesUploadRequest, S as SavingRequest, T as TransferRequest, U as UserCredentialRequest, e as UserCredentialUpdateRequest, f as UserLoginRequest, g as UserUpdateRequest, h as VerificationAttemptRequest, V as VerificationRequest, W as WalletTransactionRequest } from '../walletTransactionRequest-f515485a.mjs';
2
2
  import '../errors/index.mjs';
3
- import '../data-7d3d5fcc.js';
3
+ import '../data-69952249.mjs';