@cuenca-mx/cuenca-js 0.0.1-dev.5 → 0.0.1-dev.50
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} +427 -105
- package/build/index.mjs +386 -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.50";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,7 +175,6 @@ class Client {
|
|
|
125
175
|
}
|
|
126
176
|
headers['X-Cuenca-Token'] = this.jwtToken.token;
|
|
127
177
|
}
|
|
128
|
-
|
|
129
178
|
const headersInterceptor = this.addHeadersToRequest(headers);
|
|
130
179
|
|
|
131
180
|
const modifiedData = data;
|
|
@@ -293,7 +342,13 @@ class BillPayment extends Transaction {
|
|
|
293
342
|
status,
|
|
294
343
|
userId,
|
|
295
344
|
}) {
|
|
296
|
-
super({
|
|
345
|
+
super({
|
|
346
|
+
amount,
|
|
347
|
+
createdAt,
|
|
348
|
+
descriptor,
|
|
349
|
+
status,
|
|
350
|
+
userId,
|
|
351
|
+
});
|
|
297
352
|
this.accountNumber = accountNumber;
|
|
298
353
|
this.id = id;
|
|
299
354
|
this.providerUri = providerUri;
|
|
@@ -407,7 +462,13 @@ class CardTransaction extends Transaction {
|
|
|
407
462
|
type,
|
|
408
463
|
userId,
|
|
409
464
|
}) {
|
|
410
|
-
super({
|
|
465
|
+
super({
|
|
466
|
+
amount,
|
|
467
|
+
createdAt,
|
|
468
|
+
descriptor,
|
|
469
|
+
status,
|
|
470
|
+
userId,
|
|
471
|
+
});
|
|
411
472
|
this.cardErrorType = enumValueFromString(CardErrorType, cardErrorType);
|
|
412
473
|
this.cardLastFour = cardLastFour;
|
|
413
474
|
this.cardType = enumValueFromString(CardType, cardType);
|
|
@@ -504,7 +565,13 @@ class Commission extends Transaction {
|
|
|
504
565
|
type,
|
|
505
566
|
userId,
|
|
506
567
|
}) {
|
|
507
|
-
super({
|
|
568
|
+
super({
|
|
569
|
+
amount,
|
|
570
|
+
createdAt,
|
|
571
|
+
descriptor,
|
|
572
|
+
status,
|
|
573
|
+
userId,
|
|
574
|
+
});
|
|
508
575
|
this.relatedTransactionUri = relatedTransactionUri;
|
|
509
576
|
this.type = enumValueFromString(CommissionType, type);
|
|
510
577
|
}
|
|
@@ -533,7 +600,13 @@ class Deposit extends Transaction {
|
|
|
533
600
|
trackingKey,
|
|
534
601
|
userId,
|
|
535
602
|
}) {
|
|
536
|
-
super({
|
|
603
|
+
super({
|
|
604
|
+
amount,
|
|
605
|
+
createdAt,
|
|
606
|
+
descriptor,
|
|
607
|
+
status,
|
|
608
|
+
userId,
|
|
609
|
+
});
|
|
537
610
|
this.id = id;
|
|
538
611
|
this.network = enumValueFromString(DepositNetwork, network);
|
|
539
612
|
this.sourceUri = sourceUri;
|
|
@@ -554,6 +627,96 @@ class Deposit extends Transaction {
|
|
|
554
627
|
});
|
|
555
628
|
}
|
|
556
629
|
|
|
630
|
+
class Identities {
|
|
631
|
+
constructor({
|
|
632
|
+
address,
|
|
633
|
+
blacklistValidationStatus,
|
|
634
|
+
countryOfBirth,
|
|
635
|
+
createdAt,
|
|
636
|
+
curp,
|
|
637
|
+
dateOfBirth,
|
|
638
|
+
extension,
|
|
639
|
+
firstSurname,
|
|
640
|
+
gender,
|
|
641
|
+
govId,
|
|
642
|
+
id,
|
|
643
|
+
names,
|
|
644
|
+
nationality,
|
|
645
|
+
proofOfAddress,
|
|
646
|
+
proofOfLife,
|
|
647
|
+
rfc,
|
|
648
|
+
rfcDocument,
|
|
649
|
+
rfcFile,
|
|
650
|
+
secondSurname,
|
|
651
|
+
stateOfBirth,
|
|
652
|
+
status,
|
|
653
|
+
tosAgreement,
|
|
654
|
+
userId,
|
|
655
|
+
}) {
|
|
656
|
+
this.address = address;
|
|
657
|
+
this.blacklistValidationStatus = blacklistValidationStatus;
|
|
658
|
+
this.countryOfBirth = countryOfBirth;
|
|
659
|
+
this.createdAt = createdAt;
|
|
660
|
+
this.curp = curp;
|
|
661
|
+
this.dateOfBirth = dateOfBirth;
|
|
662
|
+
this.extension = extension;
|
|
663
|
+
this.firstSurname = firstSurname;
|
|
664
|
+
this.gender = gender;
|
|
665
|
+
this.govId = govId;
|
|
666
|
+
this.id = id;
|
|
667
|
+
this.names = names;
|
|
668
|
+
this.nationality = nationality;
|
|
669
|
+
this.proofOfAddress = proofOfAddress;
|
|
670
|
+
this.proofOfLife = proofOfLife;
|
|
671
|
+
this.rfc = rfc;
|
|
672
|
+
this.rfcDocument = rfcDocument;
|
|
673
|
+
this.rfcFile = rfcFile;
|
|
674
|
+
this.secondSurname = secondSurname;
|
|
675
|
+
this.stateOfBirth = stateOfBirth;
|
|
676
|
+
this.status = status;
|
|
677
|
+
this.tosAgreement = tosAgreement;
|
|
678
|
+
this.userId = userId;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
static fromObject = ({
|
|
682
|
+
address,
|
|
683
|
+
curp,
|
|
684
|
+
extension,
|
|
685
|
+
gender,
|
|
686
|
+
id,
|
|
687
|
+
names,
|
|
688
|
+
nationality,
|
|
689
|
+
rfc,
|
|
690
|
+
status,
|
|
691
|
+
...obj
|
|
692
|
+
}) =>
|
|
693
|
+
new Identities({
|
|
694
|
+
address,
|
|
695
|
+
curp,
|
|
696
|
+
extension,
|
|
697
|
+
gender,
|
|
698
|
+
id,
|
|
699
|
+
names,
|
|
700
|
+
nationality,
|
|
701
|
+
rfc,
|
|
702
|
+
status,
|
|
703
|
+
blacklistValidationStatus: obj.blacklist_validation_status,
|
|
704
|
+
countryOfBirth: obj.country_of_birth,
|
|
705
|
+
createdAt: obj.created_at,
|
|
706
|
+
dateOfBirth: obj.date_of_birth,
|
|
707
|
+
firstSurname: obj.first_surname,
|
|
708
|
+
govId: obj.gov_id,
|
|
709
|
+
proofOfAddress: obj.proof_of_address,
|
|
710
|
+
proofOfLife: obj.proof_of_life,
|
|
711
|
+
rfcDocument: obj.rfc_document,
|
|
712
|
+
rfcFile: obj.rfc_file,
|
|
713
|
+
secondSurname: obj.second_surname,
|
|
714
|
+
stateOfBirth: obj.state_of_birth,
|
|
715
|
+
tosAgreement: obj.tos_agreement,
|
|
716
|
+
userId: obj.user_id,
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
|
|
557
720
|
class LoginToken {
|
|
558
721
|
constructor({ id }) {
|
|
559
722
|
this.id = id;
|
|
@@ -586,7 +749,14 @@ class Saving extends Wallet {
|
|
|
586
749
|
userId,
|
|
587
750
|
updatedAt,
|
|
588
751
|
}) {
|
|
589
|
-
super({
|
|
752
|
+
super({
|
|
753
|
+
balance,
|
|
754
|
+
createdAt,
|
|
755
|
+
deactivatedAt,
|
|
756
|
+
id,
|
|
757
|
+
userId,
|
|
758
|
+
updatedAt,
|
|
759
|
+
});
|
|
590
760
|
this.category = enumValueFromString(SavingCategory, category);
|
|
591
761
|
this.goalAmount = goalAmount;
|
|
592
762
|
this.goalDate = dateToUTC(goalDate);
|
|
@@ -665,7 +835,13 @@ class Transfer extends Transaction {
|
|
|
665
835
|
updatedAt,
|
|
666
836
|
userId,
|
|
667
837
|
}) {
|
|
668
|
-
super({
|
|
838
|
+
super({
|
|
839
|
+
amount,
|
|
840
|
+
createdAt,
|
|
841
|
+
descriptor,
|
|
842
|
+
status,
|
|
843
|
+
userId,
|
|
844
|
+
});
|
|
669
845
|
this.accountNumber = accountNumber;
|
|
670
846
|
this.destinationUri = destinationUri;
|
|
671
847
|
this.id = id;
|
|
@@ -694,6 +870,82 @@ class Transfer extends Transaction {
|
|
|
694
870
|
});
|
|
695
871
|
}
|
|
696
872
|
|
|
873
|
+
class User {
|
|
874
|
+
constructor({
|
|
875
|
+
emailAddress,
|
|
876
|
+
govtId,
|
|
877
|
+
identityUri,
|
|
878
|
+
level,
|
|
879
|
+
phoneNumber,
|
|
880
|
+
proofOfAddress,
|
|
881
|
+
proofOfLife,
|
|
882
|
+
status,
|
|
883
|
+
termsOfService,
|
|
884
|
+
verificationId,
|
|
885
|
+
}) {
|
|
886
|
+
this.emailAddress = emailAddress;
|
|
887
|
+
this.govstIds = govtId;
|
|
888
|
+
this.identityUri = identityUri;
|
|
889
|
+
this.level = level;
|
|
890
|
+
this.phoneNumber = phoneNumber;
|
|
891
|
+
this.addressProofs = proofOfAddress;
|
|
892
|
+
this.lifeProofs = proofOfLife;
|
|
893
|
+
this.status = enumValueFromString(UserStatus, status);
|
|
894
|
+
this.terms = termsOfService;
|
|
895
|
+
this.verificationId = verificationId;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
get proofOfAddress() {
|
|
899
|
+
return this._proofOfAddress;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
set addressProofs(value) {
|
|
903
|
+
if (!value) return;
|
|
904
|
+
this._proofOfAddress = KYCFile.fromObject(value);
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
get proofOfLife() {
|
|
908
|
+
return this._proofOfLife;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
set lifeProofs(value) {
|
|
912
|
+
if (!value) return;
|
|
913
|
+
this._proofOfLife = KYCFile.fromObject(value);
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
get govtId() {
|
|
917
|
+
return this._govtId;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
set govstIds(value) {
|
|
921
|
+
if (!value) return;
|
|
922
|
+
this._govtId = KYCFile.fromObject(value);
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
get termsOfService() {
|
|
926
|
+
return this._termsOfService;
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
set terms(value) {
|
|
930
|
+
if (!value) return;
|
|
931
|
+
this._termsOfService = TOSAgreements.fromObject(value);
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
static fromObject = ({ level, status, ...obj }) =>
|
|
935
|
+
new User({
|
|
936
|
+
level,
|
|
937
|
+
status,
|
|
938
|
+
govtId: obj.govt_id,
|
|
939
|
+
identityUri: obj.identity_uri,
|
|
940
|
+
emailAddress: obj.email_address,
|
|
941
|
+
phoneNumber: obj.phone_number,
|
|
942
|
+
proofOfAddress: obj.proof_of_address,
|
|
943
|
+
proofOfLife: obj.proof_of_life,
|
|
944
|
+
termsOfService: obj.terms_of_service,
|
|
945
|
+
verificationId: obj.verification_id,
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
|
|
697
949
|
class UserCredential {
|
|
698
950
|
constructor({ createdAt, id, isActive, updatedAt }) {
|
|
699
951
|
this.createdAt = dateToUTC(createdAt);
|
|
@@ -726,6 +978,27 @@ class UserLogin {
|
|
|
726
978
|
});
|
|
727
979
|
}
|
|
728
980
|
|
|
981
|
+
class Verification {
|
|
982
|
+
constructor({ createdAt, id, platformId, recipient, type, updatedAt }) {
|
|
983
|
+
this.createdAt = dateToUTC(createdAt);
|
|
984
|
+
this.id = id;
|
|
985
|
+
this.platformId = platformId;
|
|
986
|
+
this.recipient = recipient;
|
|
987
|
+
this.type = enumValueFromString(VerificationType, type);
|
|
988
|
+
this.updatedAt = dateToUTC(updatedAt);
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
static fromObject = ({ id, recipient, type, ...obj }) =>
|
|
992
|
+
new Verification({
|
|
993
|
+
id,
|
|
994
|
+
recipient,
|
|
995
|
+
type,
|
|
996
|
+
createdAt: obj.created_at,
|
|
997
|
+
platformId: obj.platform_id,
|
|
998
|
+
updatedAt: obj.updated_at,
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
|
|
729
1002
|
class WalletTransaction extends Transaction {
|
|
730
1003
|
constructor({
|
|
731
1004
|
amount,
|
|
@@ -737,7 +1010,13 @@ class WalletTransaction extends Transaction {
|
|
|
737
1010
|
userId,
|
|
738
1011
|
walletUri,
|
|
739
1012
|
}) {
|
|
740
|
-
super({
|
|
1013
|
+
super({
|
|
1014
|
+
amount,
|
|
1015
|
+
createdAt,
|
|
1016
|
+
descriptor,
|
|
1017
|
+
status,
|
|
1018
|
+
userId,
|
|
1019
|
+
});
|
|
741
1020
|
this.id = id;
|
|
742
1021
|
this.transactionType = enumValueFromString(
|
|
743
1022
|
WalletTransactionType,
|
|
@@ -776,7 +1055,13 @@ class WhatsAppTransfer extends Transaction {
|
|
|
776
1055
|
updatedAt,
|
|
777
1056
|
userId,
|
|
778
1057
|
}) {
|
|
779
|
-
super({
|
|
1058
|
+
super({
|
|
1059
|
+
amount,
|
|
1060
|
+
createdAt,
|
|
1061
|
+
descriptor,
|
|
1062
|
+
status,
|
|
1063
|
+
userId,
|
|
1064
|
+
});
|
|
780
1065
|
this.claimUrl = claimUrl;
|
|
781
1066
|
this.destinationUri = destinationUri;
|
|
782
1067
|
this.id = id;
|
|
@@ -832,13 +1117,16 @@ const getModelFromPath = (path, obj) => {
|
|
|
832
1117
|
card_validations: () => CardValidation.fromObject(obj),
|
|
833
1118
|
commissions: () => Commission.fromObject(obj),
|
|
834
1119
|
deposits: () => Deposit.fromObject(obj),
|
|
1120
|
+
identities: () => Identities.fromObject(obj),
|
|
835
1121
|
login_tokens: () => LoginToken.fromObject(obj),
|
|
836
1122
|
savings: () => Saving.fromObject(obj),
|
|
837
1123
|
service_providers: () => ServiceProvider.fromObject(obj),
|
|
838
1124
|
statements: () => Statement.fromObject(obj),
|
|
839
1125
|
transfers: () => Transfer.fromObject(obj),
|
|
1126
|
+
users: () => User.fromObject(obj),
|
|
840
1127
|
user_credentials: () => UserCredential.fromObject(obj),
|
|
841
1128
|
user_logins: () => UserLogin.fromObject(obj),
|
|
1129
|
+
verifications: () => Verification.fromObject(obj),
|
|
842
1130
|
wallet_transactions: () => WalletTransaction.fromObject(obj),
|
|
843
1131
|
whatsapp_transfers: () => WhatsAppTransfer.fromObject(obj),
|
|
844
1132
|
};
|
|
@@ -895,6 +1183,19 @@ const Updateable = (SuperClass) =>
|
|
|
895
1183
|
}
|
|
896
1184
|
};
|
|
897
1185
|
|
|
1186
|
+
const Uploadable = (SuperClass) =>
|
|
1187
|
+
class Uploadable extends SuperClass {
|
|
1188
|
+
async _upload(id, data) {
|
|
1189
|
+
const response = await this.client.patch({
|
|
1190
|
+
endpoint: `/${this.path}/${id}`,
|
|
1191
|
+
data,
|
|
1192
|
+
multipart: true,
|
|
1193
|
+
});
|
|
1194
|
+
const model = getModelFromPath(this.path, response);
|
|
1195
|
+
return model;
|
|
1196
|
+
}
|
|
1197
|
+
};
|
|
1198
|
+
|
|
898
1199
|
const Deactivable = (SuperClass) =>
|
|
899
1200
|
class Deactivable extends SuperClass {
|
|
900
1201
|
async _deactivate(id, data) {
|
|
@@ -1207,6 +1508,19 @@ class DepositResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
|
1207
1508
|
}
|
|
1208
1509
|
}
|
|
1209
1510
|
|
|
1511
|
+
class IdentitiesResource extends mix(Resource).with(Uploadable) {
|
|
1512
|
+
constructor(client) {
|
|
1513
|
+
super('identities', Object, client);
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
async upload({ extension, id, rfcFile, userId = 'me' }) {
|
|
1517
|
+
const request = new IdentitiesUploadRequest({ extension, rfcFile, userId });
|
|
1518
|
+
const identities = await this._upload(id, request.toObject());
|
|
1519
|
+
// const identities = await this._update(identityId, request.toObject());
|
|
1520
|
+
return identities;
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1210
1524
|
class LoginTokenResource extends mix(Resource).with(Creatable) {
|
|
1211
1525
|
constructor(client) {
|
|
1212
1526
|
super('login_tokens', Object, client);
|
|
@@ -1398,6 +1712,40 @@ class UserLoginResource extends mix(Resource).with(Creatable, Deactivable) {
|
|
|
1398
1712
|
}
|
|
1399
1713
|
}
|
|
1400
1714
|
|
|
1715
|
+
class UserResourse extends mix(Resource).with(
|
|
1716
|
+
Queryable,
|
|
1717
|
+
Updateable,
|
|
1718
|
+
Retrievable,
|
|
1719
|
+
) {
|
|
1720
|
+
constructor(client) {
|
|
1721
|
+
super('users', UserQuery, client);
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
async update({ termsOfService, verificationId, userId = 'me' }) {
|
|
1725
|
+
const request = new UserUpdateRequest({ termsOfService, verificationId });
|
|
1726
|
+
const user = await this._update(userId, request.toCleanObject());
|
|
1727
|
+
return user;
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
class VerificationResourse extends mix(Resource).with(Creatable, Updateable) {
|
|
1732
|
+
constructor(client) {
|
|
1733
|
+
super('verifications', Object, client);
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
async create({ platformId, recipient, type }) {
|
|
1737
|
+
const request = new VerificationRequest({ platformId, recipient, type });
|
|
1738
|
+
const verification = await this._create(request.toObject());
|
|
1739
|
+
return verification;
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
async update({ code, id }) {
|
|
1743
|
+
const request = new VerificationAttemptRequest({ code });
|
|
1744
|
+
const verification = await this._update(id, request.toObject());
|
|
1745
|
+
return verification;
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
|
|
1401
1749
|
class WalletTransactionsResource extends mix(Resource).with(
|
|
1402
1750
|
Creatable,
|
|
1403
1751
|
Queryable,
|
|
@@ -1444,8 +1792,13 @@ class WhatsAppTransferResource extends mix(Resource).with(
|
|
|
1444
1792
|
}
|
|
1445
1793
|
|
|
1446
1794
|
class Cuenca {
|
|
1447
|
-
constructor(
|
|
1448
|
-
|
|
1795
|
+
constructor({
|
|
1796
|
+
apiKey,
|
|
1797
|
+
apiSecret,
|
|
1798
|
+
language = 'en',
|
|
1799
|
+
phase = Phase.Sandbox,
|
|
1800
|
+
} = {}) {
|
|
1801
|
+
this.client = new Client({ apiKey, apiSecret, language, phase });
|
|
1449
1802
|
this.withClient(this.client);
|
|
1450
1803
|
}
|
|
1451
1804
|
|
|
@@ -1460,6 +1813,7 @@ class Cuenca {
|
|
|
1460
1813
|
this.cardValidations = new CardValidationResource(client);
|
|
1461
1814
|
this.commissions = new CommissionResource(client);
|
|
1462
1815
|
this.deposits = new DepositResource(client);
|
|
1816
|
+
this.identities = new IdentitiesResource(client);
|
|
1463
1817
|
this.loginTokens = new LoginTokenResource(client);
|
|
1464
1818
|
this.savings = new SavingResource(client);
|
|
1465
1819
|
this.serviceProviders = new ServiceProviderResource(client);
|
|
@@ -1467,6 +1821,8 @@ class Cuenca {
|
|
|
1467
1821
|
this.transfers = new TransferResource(client);
|
|
1468
1822
|
this.userCredentials = new UserCredentialResource(client);
|
|
1469
1823
|
this.userLogins = new UserLoginResource(client);
|
|
1824
|
+
this.users = new UserResourse(client);
|
|
1825
|
+
this.verifications = new VerificationResourse(client);
|
|
1470
1826
|
this.walletTransactions = new WalletTransactionsResource(client);
|
|
1471
1827
|
this.whatsAppTransfers = new WhatsAppTransferResource(client);
|
|
1472
1828
|
}
|
|
@@ -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';
|