@cuenca-mx/cuenca-js 0.0.1-dev.5 → 0.0.1-dev.52
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/README.md +157 -2
- package/build/data-69952249.mjs +330 -0
- package/build/{queries-b8f29837.js → data-efb53250.cjs} +62 -285
- package/build/errors/{index.js → index.cjs} +0 -0
- package/build/identities-5e48f342.mjs +337 -0
- package/build/identities-93faf1ed.cjs +354 -0
- package/build/{index.js → index.cjs} +429 -105
- package/build/index.mjs +388 -30
- package/build/jwt/{index.js → index.cjs} +7 -2
- package/build/jwt/index.mjs +2 -1
- package/build/requests/{index.js → index.cjs} +7 -3
- package/build/requests/index.mjs +2 -2
- package/build/types/index.cjs +47 -0
- package/build/types/index.mjs +2 -2
- package/build/umd/cuenca.umd.js +1 -1
- package/build/{walletTransactionRequest-bbfb87bd.js → walletTransactionRequest-949af51e.mjs} +208 -4
- package/build/{walletTransactionRequest-b588cc52.js → walletTransactionRequest-c67b6b94.cjs} +212 -4
- package/package.json +26 -12
- package/build/README.md +0 -7
- package/build/data-7d3d5fcc.js +0 -11
- package/build/data-c53f1052.js +0 -14
- package/build/package.json +0 -37
- package/build/queries-f146b91b.js +0 -546
- package/build/types/index.js +0 -40
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
|
-
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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-949af51e.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.1-dev.52";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"};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({
|
|
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
|
-
|
|
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({
|
|
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,6 +114,10 @@ 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 }) {
|
|
@@ -97,8 +128,8 @@ class Client {
|
|
|
97
128
|
return this.request({ method: 'POST', endpoint, data });
|
|
98
129
|
}
|
|
99
130
|
|
|
100
|
-
async patch({ endpoint, data }) {
|
|
101
|
-
return this.request({ method: 'PATCH', endpoint, data });
|
|
131
|
+
async patch({ endpoint, data, multipart }) {
|
|
132
|
+
return this.request({ method: 'PATCH', endpoint, data, multipart });
|
|
102
133
|
}
|
|
103
134
|
|
|
104
135
|
async delete({ endpoint, data }) {
|
|
@@ -110,14 +141,33 @@ 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
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
147
|
+
console.log('multipart :', multipart);
|
|
148
|
+
let headers;
|
|
149
|
+
if (multipart) {
|
|
150
|
+
headers = {
|
|
151
|
+
'Content-Type': 'multipart/form-data',
|
|
152
|
+
};
|
|
153
|
+
} else {
|
|
154
|
+
headers = {
|
|
155
|
+
'Content-Type': 'application/json',
|
|
156
|
+
Accept: `application/${format.value}`,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (this.authHeader) {
|
|
161
|
+
headers.Authorization = this.authHeader;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (runtimeEnv.isNode) {
|
|
165
|
+
headers['User-Agent'] = `cuenca-js/${pkg.version}`;
|
|
166
|
+
} else if (runtimeEnv.isBrowser) {
|
|
167
|
+
// Cannot set User-Agent header on browsers
|
|
168
|
+
// https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name
|
|
169
|
+
headers['X-User-Agent'] = `cuenca-js/${pkg.version}`;
|
|
170
|
+
}
|
|
121
171
|
|
|
122
172
|
if (this.jwtToken) {
|
|
123
173
|
if (this.jwtToken.isExpired) {
|
|
@@ -125,8 +175,9 @@ class Client {
|
|
|
125
175
|
}
|
|
126
176
|
headers['X-Cuenca-Token'] = this.jwtToken.token;
|
|
127
177
|
}
|
|
128
|
-
|
|
178
|
+
console.log('headers :', headers);
|
|
129
179
|
const headersInterceptor = this.addHeadersToRequest(headers);
|
|
180
|
+
console.log('headersInterceptor :', headersInterceptor);
|
|
130
181
|
|
|
131
182
|
const modifiedData = data;
|
|
132
183
|
if (modifiedData) {
|
|
@@ -293,7 +344,13 @@ class BillPayment extends Transaction {
|
|
|
293
344
|
status,
|
|
294
345
|
userId,
|
|
295
346
|
}) {
|
|
296
|
-
super({
|
|
347
|
+
super({
|
|
348
|
+
amount,
|
|
349
|
+
createdAt,
|
|
350
|
+
descriptor,
|
|
351
|
+
status,
|
|
352
|
+
userId,
|
|
353
|
+
});
|
|
297
354
|
this.accountNumber = accountNumber;
|
|
298
355
|
this.id = id;
|
|
299
356
|
this.providerUri = providerUri;
|
|
@@ -407,7 +464,13 @@ class CardTransaction extends Transaction {
|
|
|
407
464
|
type,
|
|
408
465
|
userId,
|
|
409
466
|
}) {
|
|
410
|
-
super({
|
|
467
|
+
super({
|
|
468
|
+
amount,
|
|
469
|
+
createdAt,
|
|
470
|
+
descriptor,
|
|
471
|
+
status,
|
|
472
|
+
userId,
|
|
473
|
+
});
|
|
411
474
|
this.cardErrorType = enumValueFromString(CardErrorType, cardErrorType);
|
|
412
475
|
this.cardLastFour = cardLastFour;
|
|
413
476
|
this.cardType = enumValueFromString(CardType, cardType);
|
|
@@ -504,7 +567,13 @@ class Commission extends Transaction {
|
|
|
504
567
|
type,
|
|
505
568
|
userId,
|
|
506
569
|
}) {
|
|
507
|
-
super({
|
|
570
|
+
super({
|
|
571
|
+
amount,
|
|
572
|
+
createdAt,
|
|
573
|
+
descriptor,
|
|
574
|
+
status,
|
|
575
|
+
userId,
|
|
576
|
+
});
|
|
508
577
|
this.relatedTransactionUri = relatedTransactionUri;
|
|
509
578
|
this.type = enumValueFromString(CommissionType, type);
|
|
510
579
|
}
|
|
@@ -533,7 +602,13 @@ class Deposit extends Transaction {
|
|
|
533
602
|
trackingKey,
|
|
534
603
|
userId,
|
|
535
604
|
}) {
|
|
536
|
-
super({
|
|
605
|
+
super({
|
|
606
|
+
amount,
|
|
607
|
+
createdAt,
|
|
608
|
+
descriptor,
|
|
609
|
+
status,
|
|
610
|
+
userId,
|
|
611
|
+
});
|
|
537
612
|
this.id = id;
|
|
538
613
|
this.network = enumValueFromString(DepositNetwork, network);
|
|
539
614
|
this.sourceUri = sourceUri;
|
|
@@ -554,6 +629,96 @@ class Deposit extends Transaction {
|
|
|
554
629
|
});
|
|
555
630
|
}
|
|
556
631
|
|
|
632
|
+
class Identities {
|
|
633
|
+
constructor({
|
|
634
|
+
address,
|
|
635
|
+
blacklistValidationStatus,
|
|
636
|
+
countryOfBirth,
|
|
637
|
+
createdAt,
|
|
638
|
+
curp,
|
|
639
|
+
dateOfBirth,
|
|
640
|
+
extension,
|
|
641
|
+
firstSurname,
|
|
642
|
+
gender,
|
|
643
|
+
govId,
|
|
644
|
+
id,
|
|
645
|
+
names,
|
|
646
|
+
nationality,
|
|
647
|
+
proofOfAddress,
|
|
648
|
+
proofOfLife,
|
|
649
|
+
rfc,
|
|
650
|
+
rfcDocument,
|
|
651
|
+
rfcFile,
|
|
652
|
+
secondSurname,
|
|
653
|
+
stateOfBirth,
|
|
654
|
+
status,
|
|
655
|
+
tosAgreement,
|
|
656
|
+
userId,
|
|
657
|
+
}) {
|
|
658
|
+
this.address = address;
|
|
659
|
+
this.blacklistValidationStatus = blacklistValidationStatus;
|
|
660
|
+
this.countryOfBirth = countryOfBirth;
|
|
661
|
+
this.createdAt = createdAt;
|
|
662
|
+
this.curp = curp;
|
|
663
|
+
this.dateOfBirth = dateOfBirth;
|
|
664
|
+
this.extension = extension;
|
|
665
|
+
this.firstSurname = firstSurname;
|
|
666
|
+
this.gender = gender;
|
|
667
|
+
this.govId = govId;
|
|
668
|
+
this.id = id;
|
|
669
|
+
this.names = names;
|
|
670
|
+
this.nationality = nationality;
|
|
671
|
+
this.proofOfAddress = proofOfAddress;
|
|
672
|
+
this.proofOfLife = proofOfLife;
|
|
673
|
+
this.rfc = rfc;
|
|
674
|
+
this.rfcDocument = rfcDocument;
|
|
675
|
+
this.rfcFile = rfcFile;
|
|
676
|
+
this.secondSurname = secondSurname;
|
|
677
|
+
this.stateOfBirth = stateOfBirth;
|
|
678
|
+
this.status = status;
|
|
679
|
+
this.tosAgreement = tosAgreement;
|
|
680
|
+
this.userId = userId;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
static fromObject = ({
|
|
684
|
+
address,
|
|
685
|
+
curp,
|
|
686
|
+
extension,
|
|
687
|
+
gender,
|
|
688
|
+
id,
|
|
689
|
+
names,
|
|
690
|
+
nationality,
|
|
691
|
+
rfc,
|
|
692
|
+
status,
|
|
693
|
+
...obj
|
|
694
|
+
}) =>
|
|
695
|
+
new Identities({
|
|
696
|
+
address,
|
|
697
|
+
curp,
|
|
698
|
+
extension,
|
|
699
|
+
gender,
|
|
700
|
+
id,
|
|
701
|
+
names,
|
|
702
|
+
nationality,
|
|
703
|
+
rfc,
|
|
704
|
+
status,
|
|
705
|
+
blacklistValidationStatus: obj.blacklist_validation_status,
|
|
706
|
+
countryOfBirth: obj.country_of_birth,
|
|
707
|
+
createdAt: obj.created_at,
|
|
708
|
+
dateOfBirth: obj.date_of_birth,
|
|
709
|
+
firstSurname: obj.first_surname,
|
|
710
|
+
govId: obj.gov_id,
|
|
711
|
+
proofOfAddress: obj.proof_of_address,
|
|
712
|
+
proofOfLife: obj.proof_of_life,
|
|
713
|
+
rfcDocument: obj.rfc_document,
|
|
714
|
+
rfcFile: obj.rfc_file,
|
|
715
|
+
secondSurname: obj.second_surname,
|
|
716
|
+
stateOfBirth: obj.state_of_birth,
|
|
717
|
+
tosAgreement: obj.tos_agreement,
|
|
718
|
+
userId: obj.user_id,
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
|
|
557
722
|
class LoginToken {
|
|
558
723
|
constructor({ id }) {
|
|
559
724
|
this.id = id;
|
|
@@ -586,7 +751,14 @@ class Saving extends Wallet {
|
|
|
586
751
|
userId,
|
|
587
752
|
updatedAt,
|
|
588
753
|
}) {
|
|
589
|
-
super({
|
|
754
|
+
super({
|
|
755
|
+
balance,
|
|
756
|
+
createdAt,
|
|
757
|
+
deactivatedAt,
|
|
758
|
+
id,
|
|
759
|
+
userId,
|
|
760
|
+
updatedAt,
|
|
761
|
+
});
|
|
590
762
|
this.category = enumValueFromString(SavingCategory, category);
|
|
591
763
|
this.goalAmount = goalAmount;
|
|
592
764
|
this.goalDate = dateToUTC(goalDate);
|
|
@@ -665,7 +837,13 @@ class Transfer extends Transaction {
|
|
|
665
837
|
updatedAt,
|
|
666
838
|
userId,
|
|
667
839
|
}) {
|
|
668
|
-
super({
|
|
840
|
+
super({
|
|
841
|
+
amount,
|
|
842
|
+
createdAt,
|
|
843
|
+
descriptor,
|
|
844
|
+
status,
|
|
845
|
+
userId,
|
|
846
|
+
});
|
|
669
847
|
this.accountNumber = accountNumber;
|
|
670
848
|
this.destinationUri = destinationUri;
|
|
671
849
|
this.id = id;
|
|
@@ -694,6 +872,82 @@ class Transfer extends Transaction {
|
|
|
694
872
|
});
|
|
695
873
|
}
|
|
696
874
|
|
|
875
|
+
class User {
|
|
876
|
+
constructor({
|
|
877
|
+
emailAddress,
|
|
878
|
+
govtId,
|
|
879
|
+
identityUri,
|
|
880
|
+
level,
|
|
881
|
+
phoneNumber,
|
|
882
|
+
proofOfAddress,
|
|
883
|
+
proofOfLife,
|
|
884
|
+
status,
|
|
885
|
+
termsOfService,
|
|
886
|
+
verificationId,
|
|
887
|
+
}) {
|
|
888
|
+
this.emailAddress = emailAddress;
|
|
889
|
+
this.govstIds = govtId;
|
|
890
|
+
this.identityUri = identityUri;
|
|
891
|
+
this.level = level;
|
|
892
|
+
this.phoneNumber = phoneNumber;
|
|
893
|
+
this.addressProofs = proofOfAddress;
|
|
894
|
+
this.lifeProofs = proofOfLife;
|
|
895
|
+
this.status = enumValueFromString(UserStatus, status);
|
|
896
|
+
this.terms = termsOfService;
|
|
897
|
+
this.verificationId = verificationId;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
get proofOfAddress() {
|
|
901
|
+
return this._proofOfAddress;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
set addressProofs(value) {
|
|
905
|
+
if (!value) return;
|
|
906
|
+
this._proofOfAddress = KYCFile.fromObject(value);
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
get proofOfLife() {
|
|
910
|
+
return this._proofOfLife;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
set lifeProofs(value) {
|
|
914
|
+
if (!value) return;
|
|
915
|
+
this._proofOfLife = KYCFile.fromObject(value);
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
get govtId() {
|
|
919
|
+
return this._govtId;
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
set govstIds(value) {
|
|
923
|
+
if (!value) return;
|
|
924
|
+
this._govtId = KYCFile.fromObject(value);
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
get termsOfService() {
|
|
928
|
+
return this._termsOfService;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
set terms(value) {
|
|
932
|
+
if (!value) return;
|
|
933
|
+
this._termsOfService = TOSAgreements.fromObject(value);
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
static fromObject = ({ level, status, ...obj }) =>
|
|
937
|
+
new User({
|
|
938
|
+
level,
|
|
939
|
+
status,
|
|
940
|
+
govtId: obj.govt_id,
|
|
941
|
+
identityUri: obj.identity_uri,
|
|
942
|
+
emailAddress: obj.email_address,
|
|
943
|
+
phoneNumber: obj.phone_number,
|
|
944
|
+
proofOfAddress: obj.proof_of_address,
|
|
945
|
+
proofOfLife: obj.proof_of_life,
|
|
946
|
+
termsOfService: obj.terms_of_service,
|
|
947
|
+
verificationId: obj.verification_id,
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
|
|
697
951
|
class UserCredential {
|
|
698
952
|
constructor({ createdAt, id, isActive, updatedAt }) {
|
|
699
953
|
this.createdAt = dateToUTC(createdAt);
|
|
@@ -726,6 +980,27 @@ class UserLogin {
|
|
|
726
980
|
});
|
|
727
981
|
}
|
|
728
982
|
|
|
983
|
+
class Verification {
|
|
984
|
+
constructor({ createdAt, id, platformId, recipient, type, updatedAt }) {
|
|
985
|
+
this.createdAt = dateToUTC(createdAt);
|
|
986
|
+
this.id = id;
|
|
987
|
+
this.platformId = platformId;
|
|
988
|
+
this.recipient = recipient;
|
|
989
|
+
this.type = enumValueFromString(VerificationType, type);
|
|
990
|
+
this.updatedAt = dateToUTC(updatedAt);
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
static fromObject = ({ id, recipient, type, ...obj }) =>
|
|
994
|
+
new Verification({
|
|
995
|
+
id,
|
|
996
|
+
recipient,
|
|
997
|
+
type,
|
|
998
|
+
createdAt: obj.created_at,
|
|
999
|
+
platformId: obj.platform_id,
|
|
1000
|
+
updatedAt: obj.updated_at,
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
|
|
729
1004
|
class WalletTransaction extends Transaction {
|
|
730
1005
|
constructor({
|
|
731
1006
|
amount,
|
|
@@ -737,7 +1012,13 @@ class WalletTransaction extends Transaction {
|
|
|
737
1012
|
userId,
|
|
738
1013
|
walletUri,
|
|
739
1014
|
}) {
|
|
740
|
-
super({
|
|
1015
|
+
super({
|
|
1016
|
+
amount,
|
|
1017
|
+
createdAt,
|
|
1018
|
+
descriptor,
|
|
1019
|
+
status,
|
|
1020
|
+
userId,
|
|
1021
|
+
});
|
|
741
1022
|
this.id = id;
|
|
742
1023
|
this.transactionType = enumValueFromString(
|
|
743
1024
|
WalletTransactionType,
|
|
@@ -776,7 +1057,13 @@ class WhatsAppTransfer extends Transaction {
|
|
|
776
1057
|
updatedAt,
|
|
777
1058
|
userId,
|
|
778
1059
|
}) {
|
|
779
|
-
super({
|
|
1060
|
+
super({
|
|
1061
|
+
amount,
|
|
1062
|
+
createdAt,
|
|
1063
|
+
descriptor,
|
|
1064
|
+
status,
|
|
1065
|
+
userId,
|
|
1066
|
+
});
|
|
780
1067
|
this.claimUrl = claimUrl;
|
|
781
1068
|
this.destinationUri = destinationUri;
|
|
782
1069
|
this.id = id;
|
|
@@ -832,13 +1119,16 @@ const getModelFromPath = (path, obj) => {
|
|
|
832
1119
|
card_validations: () => CardValidation.fromObject(obj),
|
|
833
1120
|
commissions: () => Commission.fromObject(obj),
|
|
834
1121
|
deposits: () => Deposit.fromObject(obj),
|
|
1122
|
+
identities: () => Identities.fromObject(obj),
|
|
835
1123
|
login_tokens: () => LoginToken.fromObject(obj),
|
|
836
1124
|
savings: () => Saving.fromObject(obj),
|
|
837
1125
|
service_providers: () => ServiceProvider.fromObject(obj),
|
|
838
1126
|
statements: () => Statement.fromObject(obj),
|
|
839
1127
|
transfers: () => Transfer.fromObject(obj),
|
|
1128
|
+
users: () => User.fromObject(obj),
|
|
840
1129
|
user_credentials: () => UserCredential.fromObject(obj),
|
|
841
1130
|
user_logins: () => UserLogin.fromObject(obj),
|
|
1131
|
+
verifications: () => Verification.fromObject(obj),
|
|
842
1132
|
wallet_transactions: () => WalletTransaction.fromObject(obj),
|
|
843
1133
|
whatsapp_transfers: () => WhatsAppTransfer.fromObject(obj),
|
|
844
1134
|
};
|
|
@@ -895,6 +1185,19 @@ const Updateable = (SuperClass) =>
|
|
|
895
1185
|
}
|
|
896
1186
|
};
|
|
897
1187
|
|
|
1188
|
+
const Uploadable = (SuperClass) =>
|
|
1189
|
+
class Uploadable extends SuperClass {
|
|
1190
|
+
async _upload(id, data) {
|
|
1191
|
+
const response = await this.client.patch({
|
|
1192
|
+
endpoint: `/${this.path}/${id}`,
|
|
1193
|
+
data,
|
|
1194
|
+
multipart: true,
|
|
1195
|
+
});
|
|
1196
|
+
const model = getModelFromPath(this.path, response);
|
|
1197
|
+
return model;
|
|
1198
|
+
}
|
|
1199
|
+
};
|
|
1200
|
+
|
|
898
1201
|
const Deactivable = (SuperClass) =>
|
|
899
1202
|
class Deactivable extends SuperClass {
|
|
900
1203
|
async _deactivate(id, data) {
|
|
@@ -1207,6 +1510,19 @@ class DepositResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
|
1207
1510
|
}
|
|
1208
1511
|
}
|
|
1209
1512
|
|
|
1513
|
+
class IdentitiesResource extends mix(Resource).with(Uploadable) {
|
|
1514
|
+
constructor(client) {
|
|
1515
|
+
super('identities', Object, client);
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
async upload({ extension, id, rfcFile, userId = 'me' }) {
|
|
1519
|
+
const request = new IdentitiesUploadRequest({ extension, rfcFile, userId });
|
|
1520
|
+
const identities = await this._upload(id, request.toObject());
|
|
1521
|
+
// const identities = await this._update(identityId, request.toObject());
|
|
1522
|
+
return identities;
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1210
1526
|
class LoginTokenResource extends mix(Resource).with(Creatable) {
|
|
1211
1527
|
constructor(client) {
|
|
1212
1528
|
super('login_tokens', Object, client);
|
|
@@ -1398,6 +1714,40 @@ class UserLoginResource extends mix(Resource).with(Creatable, Deactivable) {
|
|
|
1398
1714
|
}
|
|
1399
1715
|
}
|
|
1400
1716
|
|
|
1717
|
+
class UserResourse extends mix(Resource).with(
|
|
1718
|
+
Queryable,
|
|
1719
|
+
Updateable,
|
|
1720
|
+
Retrievable,
|
|
1721
|
+
) {
|
|
1722
|
+
constructor(client) {
|
|
1723
|
+
super('users', UserQuery, client);
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
async update({ termsOfService, verificationId, userId = 'me' }) {
|
|
1727
|
+
const request = new UserUpdateRequest({ termsOfService, verificationId });
|
|
1728
|
+
const user = await this._update(userId, request.toCleanObject());
|
|
1729
|
+
return user;
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1733
|
+
class VerificationResourse extends mix(Resource).with(Creatable, Updateable) {
|
|
1734
|
+
constructor(client) {
|
|
1735
|
+
super('verifications', Object, client);
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
async create({ platformId, recipient, type }) {
|
|
1739
|
+
const request = new VerificationRequest({ platformId, recipient, type });
|
|
1740
|
+
const verification = await this._create(request.toObject());
|
|
1741
|
+
return verification;
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
async update({ code, id }) {
|
|
1745
|
+
const request = new VerificationAttemptRequest({ code });
|
|
1746
|
+
const verification = await this._update(id, request.toObject());
|
|
1747
|
+
return verification;
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1401
1751
|
class WalletTransactionsResource extends mix(Resource).with(
|
|
1402
1752
|
Creatable,
|
|
1403
1753
|
Queryable,
|
|
@@ -1444,8 +1794,13 @@ class WhatsAppTransferResource extends mix(Resource).with(
|
|
|
1444
1794
|
}
|
|
1445
1795
|
|
|
1446
1796
|
class Cuenca {
|
|
1447
|
-
constructor(
|
|
1448
|
-
|
|
1797
|
+
constructor({
|
|
1798
|
+
apiKey,
|
|
1799
|
+
apiSecret,
|
|
1800
|
+
language = 'en',
|
|
1801
|
+
phase = Phase.Sandbox,
|
|
1802
|
+
} = {}) {
|
|
1803
|
+
this.client = new Client({ apiKey, apiSecret, language, phase });
|
|
1449
1804
|
this.withClient(this.client);
|
|
1450
1805
|
}
|
|
1451
1806
|
|
|
@@ -1460,6 +1815,7 @@ class Cuenca {
|
|
|
1460
1815
|
this.cardValidations = new CardValidationResource(client);
|
|
1461
1816
|
this.commissions = new CommissionResource(client);
|
|
1462
1817
|
this.deposits = new DepositResource(client);
|
|
1818
|
+
this.identities = new IdentitiesResource(client);
|
|
1463
1819
|
this.loginTokens = new LoginTokenResource(client);
|
|
1464
1820
|
this.savings = new SavingResource(client);
|
|
1465
1821
|
this.serviceProviders = new ServiceProviderResource(client);
|
|
@@ -1467,6 +1823,8 @@ class Cuenca {
|
|
|
1467
1823
|
this.transfers = new TransferResource(client);
|
|
1468
1824
|
this.userCredentials = new UserCredentialResource(client);
|
|
1469
1825
|
this.userLogins = new UserLoginResource(client);
|
|
1826
|
+
this.users = new UserResourse(client);
|
|
1827
|
+
this.verifications = new VerificationResourse(client);
|
|
1470
1828
|
this.walletTransactions = new WalletTransactionsResource(client);
|
|
1471
1829
|
this.whatsAppTransfers = new WhatsAppTransferResource(client);
|
|
1472
1830
|
}
|
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
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();
|
package/build/jwt/index.mjs
CHANGED
|
@@ -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-
|
|
6
|
-
require('../errors/index.
|
|
7
|
-
require('../data-
|
|
5
|
+
var walletTransactionRequest = require('../walletTransactionRequest-c67b6b94.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;
|
package/build/requests/index.mjs
CHANGED
|
@@ -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-
|
|
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-949af51e.mjs';
|
|
2
2
|
import '../errors/index.mjs';
|
|
3
|
-
import '../data-
|
|
3
|
+
import '../data-69952249.mjs';
|