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