@cuenca-mx/cuenca-js 0.0.5-dev0 → 0.0.5
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/{data-38bfc8ad.mjs → data-59d28abe.mjs} +22 -20
- package/build/{data-6451748e.cjs → data-d6c1558d.cjs} +22 -20
- package/build/{identities-0a19fb53.cjs → identities-7d3418fb.cjs} +41 -4
- package/build/{identities-1a22fcdb.mjs → identities-fed398c2.mjs} +40 -5
- package/build/index.cjs +187 -12
- package/build/index.mjs +187 -12
- package/build/requests/index.cjs +5 -2
- package/build/requests/index.mjs +3 -2
- package/build/types/index.cjs +5 -3
- package/build/types/index.mjs +2 -2
- package/build/umd/cuenca.umd.js +1 -1
- package/build/{walletTransactionRequest-2e5deaee.mjs → walletTransactionRequest-826690e7.mjs} +108 -2
- package/build/{walletTransactionRequest-267a5d18.cjs → walletTransactionRequest-d2155aa4.cjs} +109 -1
- package/package.json +3 -2
package/build/index.cjs
CHANGED
|
@@ -6,9 +6,10 @@ var axios = require('axios');
|
|
|
6
6
|
var Buffer = require('buffer');
|
|
7
7
|
var errors_index = require('./errors/index.cjs');
|
|
8
8
|
var jwt_index = require('./jwt/index.cjs');
|
|
9
|
-
var data = require('./data-
|
|
10
|
-
var identities = require('./identities-
|
|
11
|
-
var walletTransactionRequest = require('./walletTransactionRequest-
|
|
9
|
+
var data = require('./data-d6c1558d.cjs');
|
|
10
|
+
var identities = require('./identities-7d3418fb.cjs');
|
|
11
|
+
var walletTransactionRequest = require('./walletTransactionRequest-d2155aa4.cjs');
|
|
12
|
+
require('module');
|
|
12
13
|
|
|
13
14
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
15
|
|
|
@@ -26,7 +27,7 @@ const isNode =
|
|
|
26
27
|
|
|
27
28
|
const runtimeEnv = { isBrowser, isNode };
|
|
28
29
|
|
|
29
|
-
const name="@cuenca-mx/cuenca-js";const version="0.0.5
|
|
30
|
+
const name="@cuenca-mx/cuenca-js";const version="0.0.5";const description="Cuenca client for JS";const main="./build/index.cjs";const module$1="./build/index.mjs";const browser="./build/umd/cuenca.umd.js";const files=["build/**/*"];const exports$1={".":{"import":"./build/index.mjs",require:"./build/index.cjs"},"./errors":{"import":"./build/errors/index.mjs",require:"./build/errors/index.cjs"},"./jwt":{"import":"./build/jwt/index.mjs",require:"./build/jwt/index.cjs"},"./requests":{"import":"./build/requests/index.mjs",require:"./build/requests/index.cjs"},"./types":{"import":"./build/types/index.mjs",require:"./build/types/index.cjs"}};const packageManager="yarn@3.0.2";const type="module";const repository={type:"git",url:"https://github.com/cuenca-mx/cuenca-js.git",directory:"packages/cuenca-js"};const keywords=["cuenca"];const license="MIT";const bugs={url:"https://github.com/cuenca-mx/cuenca-js/issues"};const homepage="https://cuenca.com";const scripts={build:"rm -rf build/ && yarn rollup --config",test:"yarn node --experimental-vm-modules $(yarn bin jest)",publish:"yarn build && yarn npm publish"};const devDependencies={"@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^13.1.1",jest:"^27.4.5",rollup:"^2.61.1","rollup-plugin-terser":"^7.0.2"};const dependencies={axios:"^0.24.0",buffer:"^6.0.3","form-data":"^4.0.0"};var pkg = {name:name,version:version,description:description,main:main,module:module$1,browser:browser,files:files,exports:exports$1,packageManager:packageManager,type:type,repository:repository,keywords:keywords,license:license,bugs:bugs,homepage:homepage,scripts:scripts,devDependencies:devDependencies,dependencies:dependencies};
|
|
30
31
|
|
|
31
32
|
class Client {
|
|
32
33
|
constructor({
|
|
@@ -133,8 +134,8 @@ class Client {
|
|
|
133
134
|
return this.request({ endpoint, format, params });
|
|
134
135
|
}
|
|
135
136
|
|
|
136
|
-
async post({ endpoint, data }) {
|
|
137
|
-
return this.request({ method: 'POST', endpoint, data });
|
|
137
|
+
async post({ endpoint, data, multipart }) {
|
|
138
|
+
return this.request({ method: 'POST', endpoint, data, multipart });
|
|
138
139
|
}
|
|
139
140
|
|
|
140
141
|
async patch({ endpoint, data }) {
|
|
@@ -150,12 +151,18 @@ class Client {
|
|
|
150
151
|
data: data$1 = null,
|
|
151
152
|
format = data.FileFormat.Json,
|
|
152
153
|
method = 'GET',
|
|
154
|
+
multipart = false,
|
|
153
155
|
params = null,
|
|
154
156
|
}) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
157
|
+
let headers;
|
|
158
|
+
if (multipart) {
|
|
159
|
+
headers = data$1.getHeaders();
|
|
160
|
+
} else {
|
|
161
|
+
headers = {
|
|
162
|
+
'Content-Type': 'application/json',
|
|
163
|
+
Accept: `application/${format.value}`,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
159
166
|
|
|
160
167
|
if (this.authHeader) {
|
|
161
168
|
headers.Authorization = this.authHeader;
|
|
@@ -175,11 +182,10 @@ class Client {
|
|
|
175
182
|
}
|
|
176
183
|
headers['X-Cuenca-Token'] = this.jwtToken.token;
|
|
177
184
|
}
|
|
178
|
-
|
|
179
185
|
const headersInterceptor = this.addHeadersToRequest(headers);
|
|
180
186
|
|
|
181
187
|
const modifiedData = data$1;
|
|
182
|
-
if (modifiedData) {
|
|
188
|
+
if (modifiedData && !multipart) {
|
|
183
189
|
Object.keys(modifiedData).forEach((k) => {
|
|
184
190
|
if (modifiedData[k] instanceof Date) {
|
|
185
191
|
modifiedData[k] = modifiedData[k].toISOString();
|
|
@@ -368,6 +374,67 @@ class BillPayment extends Transaction {
|
|
|
368
374
|
});
|
|
369
375
|
}
|
|
370
376
|
|
|
377
|
+
class BridgeAccount {
|
|
378
|
+
constructor({
|
|
379
|
+
id,
|
|
380
|
+
names,
|
|
381
|
+
firstSurname,
|
|
382
|
+
secondSurname,
|
|
383
|
+
dateOfBirth,
|
|
384
|
+
countryOfBirth,
|
|
385
|
+
rfc,
|
|
386
|
+
curp,
|
|
387
|
+
userId,
|
|
388
|
+
gender,
|
|
389
|
+
phoneNumber,
|
|
390
|
+
emailAddress,
|
|
391
|
+
clientClabe,
|
|
392
|
+
govtId,
|
|
393
|
+
proofOfAddress,
|
|
394
|
+
proofOfLife,
|
|
395
|
+
status,
|
|
396
|
+
}) {
|
|
397
|
+
this.id = id;
|
|
398
|
+
this.emailAddress = emailAddress;
|
|
399
|
+
this.clientClabe = clientClabe;
|
|
400
|
+
this.govtId = govtId;
|
|
401
|
+
this.names = names;
|
|
402
|
+
this.firstSurname = firstSurname;
|
|
403
|
+
this.secondSurname = secondSurname;
|
|
404
|
+
this.dateOfBirth = dateOfBirth;
|
|
405
|
+
this.countryOfBirth = countryOfBirth;
|
|
406
|
+
this.rfc = rfc;
|
|
407
|
+
this.curp = curp;
|
|
408
|
+
this.userId = userId;
|
|
409
|
+
this.gender = gender;
|
|
410
|
+
this.phoneNumber = phoneNumber;
|
|
411
|
+
this.addressProofs = proofOfAddress;
|
|
412
|
+
this.lifeProofs = proofOfLife;
|
|
413
|
+
this.status = data.enumValueFromString(data.BridgeAccountStatus, status);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
static fromObject = ({ status, ...obj }) =>
|
|
417
|
+
new BridgeAccount({
|
|
418
|
+
id: obj.id,
|
|
419
|
+
clientClabe: obj.client_clabe,
|
|
420
|
+
names: obj.names,
|
|
421
|
+
firstSurname: obj.first_surname,
|
|
422
|
+
secondSurname: obj.second_surname,
|
|
423
|
+
dateOfBirth: obj.date_of_birth,
|
|
424
|
+
countryOfBirth: obj.country_of_birth,
|
|
425
|
+
rfc: obj.rfc,
|
|
426
|
+
curp: obj.curp,
|
|
427
|
+
userId: obj.user_id,
|
|
428
|
+
gender: obj.gender,
|
|
429
|
+
govtId: obj.govt_id,
|
|
430
|
+
emailAddress: obj.email_address,
|
|
431
|
+
phoneNumber: obj.phone_number,
|
|
432
|
+
proofOfAddress: obj.proof_of_address,
|
|
433
|
+
proofOfLife: obj.proof_of_life,
|
|
434
|
+
status,
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
|
|
371
438
|
class Card {
|
|
372
439
|
constructor({
|
|
373
440
|
createdAt,
|
|
@@ -628,6 +695,35 @@ class Deposit extends Transaction {
|
|
|
628
695
|
});
|
|
629
696
|
}
|
|
630
697
|
|
|
698
|
+
class File {
|
|
699
|
+
constructor({ extension, type, url, userId }) {
|
|
700
|
+
this.extension = extension;
|
|
701
|
+
this.type = data.enumValueFromString(data.KYCFileType, type);
|
|
702
|
+
this.url = url;
|
|
703
|
+
this.userId = userId;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
static fromObject = ({ extension, type, url, ...obj }) =>
|
|
707
|
+
new File({ extension, type, url, userId: obj.user_id });
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
class KYCValidations {
|
|
711
|
+
constructor({ platformId, attemps, verificationId, filesUri }) {
|
|
712
|
+
this.attemps = attemps;
|
|
713
|
+
this.filesUri = filesUri;
|
|
714
|
+
this.platformId = platformId;
|
|
715
|
+
this.verificationId = verificationId;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
static fromObject = ({ attemps, ...obj }) =>
|
|
719
|
+
new KYCValidations({
|
|
720
|
+
attemps,
|
|
721
|
+
filesUri: obj.files_uri,
|
|
722
|
+
platformId: obj.platform_id,
|
|
723
|
+
verificationId: obj.verification_id,
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
|
|
631
727
|
class LoginToken {
|
|
632
728
|
constructor({ id }) {
|
|
633
729
|
this.id = id;
|
|
@@ -786,20 +882,25 @@ class User {
|
|
|
786
882
|
address,
|
|
787
883
|
blacklistValidationStatus,
|
|
788
884
|
clabe,
|
|
885
|
+
countryOfBirth,
|
|
789
886
|
createdAt,
|
|
790
887
|
curp,
|
|
888
|
+
dateOfBirth,
|
|
791
889
|
emailAddress,
|
|
792
890
|
firstSurname,
|
|
891
|
+
gender,
|
|
793
892
|
govtId,
|
|
794
893
|
id,
|
|
795
894
|
level,
|
|
796
895
|
names,
|
|
896
|
+
nationality,
|
|
797
897
|
phoneNumber,
|
|
798
898
|
proofOfAddress,
|
|
799
899
|
proofOfLife,
|
|
800
900
|
requiredLevel,
|
|
801
901
|
rfc,
|
|
802
902
|
secondSurname,
|
|
903
|
+
stateOfBirth,
|
|
803
904
|
status,
|
|
804
905
|
termsOfService,
|
|
805
906
|
updatedAt,
|
|
@@ -811,20 +912,25 @@ class User {
|
|
|
811
912
|
blacklistValidationStatus,
|
|
812
913
|
);
|
|
813
914
|
this.clabe = clabe;
|
|
915
|
+
this.countryOfBirth = countryOfBirth;
|
|
814
916
|
this.createdAt = data.dateToUTC(createdAt);
|
|
815
917
|
this.curp = curp;
|
|
918
|
+
this.dateOfBirth = dateOfBirth;
|
|
816
919
|
this.emailAddress = emailAddress;
|
|
817
920
|
this.firstSurname = firstSurname;
|
|
921
|
+
this.gender = gender;
|
|
818
922
|
this.govstIds = govtId;
|
|
819
923
|
this.id = id;
|
|
820
924
|
this.level = level;
|
|
821
925
|
this.names = names;
|
|
926
|
+
this.nationality = nationality;
|
|
822
927
|
this.phoneNumber = phoneNumber;
|
|
823
928
|
this.addressProofs = proofOfAddress;
|
|
824
929
|
this.lifeProofs = proofOfLife;
|
|
825
930
|
this.requiredLevel = requiredLevel;
|
|
826
931
|
this.rfc = rfc;
|
|
827
932
|
this.secondSurname = secondSurname;
|
|
933
|
+
this.stateOfBirth = stateOfBirth;
|
|
828
934
|
this.status = data.enumValueFromString(data.UserStatus, status);
|
|
829
935
|
this.terms = termsOfService;
|
|
830
936
|
this.updatedAt = data.dateToUTC(updatedAt);
|
|
@@ -880,9 +986,11 @@ class User {
|
|
|
880
986
|
address,
|
|
881
987
|
clabe,
|
|
882
988
|
curp,
|
|
989
|
+
gender,
|
|
883
990
|
id,
|
|
884
991
|
level,
|
|
885
992
|
names,
|
|
993
|
+
nationality,
|
|
886
994
|
rfc,
|
|
887
995
|
status,
|
|
888
996
|
...obj
|
|
@@ -891,13 +999,17 @@ class User {
|
|
|
891
999
|
address,
|
|
892
1000
|
clabe,
|
|
893
1001
|
curp,
|
|
1002
|
+
gender,
|
|
894
1003
|
id,
|
|
895
1004
|
level,
|
|
896
1005
|
names,
|
|
1006
|
+
nationality,
|
|
897
1007
|
rfc,
|
|
898
1008
|
status,
|
|
899
1009
|
blacklistValidationStatus: obj.blacklist_validation_status,
|
|
1010
|
+
countryOfBirth: obj.country_of_birth,
|
|
900
1011
|
createdAt: obj.created_at,
|
|
1012
|
+
dateOfBirth: obj.date_of_birth,
|
|
901
1013
|
emailAddress: obj.email_address,
|
|
902
1014
|
firstSurname: obj.first_surname,
|
|
903
1015
|
govtId: obj.govt_id,
|
|
@@ -906,6 +1018,7 @@ class User {
|
|
|
906
1018
|
proofOfLife: obj.proof_of_life,
|
|
907
1019
|
requiredLevel: obj.required_level,
|
|
908
1020
|
secondSurname: obj.second_surname,
|
|
1021
|
+
stateOfBirth: obj.state_of_birth,
|
|
909
1022
|
termsOfService: obj.terms_of_service,
|
|
910
1023
|
updatedAt: obj.updated_at,
|
|
911
1024
|
verificationId: obj.verification_id,
|
|
@@ -1077,12 +1190,15 @@ const getModelFromPath = (path, obj) => {
|
|
|
1077
1190
|
arpc: () => Arpc.fromObject(obj),
|
|
1078
1191
|
balance_entries: () => BalanceEntry.fromObject(obj),
|
|
1079
1192
|
bill_payments: () => BillPayment.fromObject(obj),
|
|
1193
|
+
'bridge/accounts': () => BridgeAccount.fromObject(obj),
|
|
1080
1194
|
cards: () => Card.fromObject(obj),
|
|
1081
1195
|
card_activations: () => CardActivation.fromObject(obj),
|
|
1082
1196
|
card_transactions: () => CardTransaction.fromObject(obj),
|
|
1083
1197
|
card_validations: () => CardValidation.fromObject(obj),
|
|
1084
1198
|
commissions: () => Commission.fromObject(obj),
|
|
1085
1199
|
deposits: () => Deposit.fromObject(obj),
|
|
1200
|
+
files: () => File.fromObject(obj),
|
|
1201
|
+
kyc_validations: () => KYCValidations.fromObject(obj),
|
|
1086
1202
|
login_tokens: () => LoginToken.fromObject(obj),
|
|
1087
1203
|
savings: () => Saving.fromObject(obj),
|
|
1088
1204
|
service_providers: () => ServiceProvider.fromObject(obj),
|
|
@@ -1148,6 +1264,19 @@ const Updateable = (SuperClass) =>
|
|
|
1148
1264
|
}
|
|
1149
1265
|
};
|
|
1150
1266
|
|
|
1267
|
+
const Uploadable = (SuperClass) =>
|
|
1268
|
+
class Uploadable extends SuperClass {
|
|
1269
|
+
async _upload(data) {
|
|
1270
|
+
const response = await this.client.post({
|
|
1271
|
+
endpoint: `/${this.path}`,
|
|
1272
|
+
data,
|
|
1273
|
+
multipart: true,
|
|
1274
|
+
});
|
|
1275
|
+
const model = getModelFromPath(this.path, response);
|
|
1276
|
+
return model;
|
|
1277
|
+
}
|
|
1278
|
+
};
|
|
1279
|
+
|
|
1151
1280
|
const Deactivable = (SuperClass) =>
|
|
1152
1281
|
class Deactivable extends SuperClass {
|
|
1153
1282
|
async _deactivate(id, data) {
|
|
@@ -1163,10 +1292,14 @@ const Deactivable = (SuperClass) =>
|
|
|
1163
1292
|
const Downlodable = (SuperClass) =>
|
|
1164
1293
|
class Downlodable extends SuperClass {
|
|
1165
1294
|
async _download(id, format) {
|
|
1295
|
+
const interceptor = this.client.addConfigToRequest({
|
|
1296
|
+
responseType: 'stream',
|
|
1297
|
+
});
|
|
1166
1298
|
const byteString = await this.client.get({
|
|
1167
1299
|
endpoint: `/${this.path}/${id}`,
|
|
1168
1300
|
format,
|
|
1169
1301
|
});
|
|
1302
|
+
interceptor.eject();
|
|
1170
1303
|
return byteString;
|
|
1171
1304
|
}
|
|
1172
1305
|
};
|
|
@@ -1333,6 +1466,12 @@ class BillPaymentResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
|
1333
1466
|
}
|
|
1334
1467
|
}
|
|
1335
1468
|
|
|
1469
|
+
class BridegAccountResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
1470
|
+
constructor(client) {
|
|
1471
|
+
super('bridge/accounts', identities.BridgeAccountQuery, client);
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1336
1475
|
class CardActivationResource extends mix(Resource).with(Creatable) {
|
|
1337
1476
|
constructor(client) {
|
|
1338
1477
|
super('card_activations', Object, client);
|
|
@@ -1460,6 +1599,39 @@ class DepositResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
|
1460
1599
|
}
|
|
1461
1600
|
}
|
|
1462
1601
|
|
|
1602
|
+
class FileResource extends mix(Resource).with(Downlodable, Uploadable) {
|
|
1603
|
+
constructor(client) {
|
|
1604
|
+
super('files', Object, client);
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
async download(id) {
|
|
1608
|
+
const byteString = await this._download(id, data.FileFormat.Any);
|
|
1609
|
+
return byteString;
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
async upload({ ...req }) {
|
|
1613
|
+
const request = new walletTransactionRequest.UploadRequest(req);
|
|
1614
|
+
const fileUpload = await this._upload(request.toFormData());
|
|
1615
|
+
return fileUpload;
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
class KYCValidationsResource extends mix(Resource).with(
|
|
1620
|
+
Creatable,
|
|
1621
|
+
Retrievable,
|
|
1622
|
+
Queryable,
|
|
1623
|
+
) {
|
|
1624
|
+
constructor(client) {
|
|
1625
|
+
super('kyc_validations', Object, client);
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
async create(userId = 'me') {
|
|
1629
|
+
const request = new walletTransactionRequest.KYCValidationsRequest(userId);
|
|
1630
|
+
const kycValidation = await this._create(request.toObject());
|
|
1631
|
+
return kycValidation;
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1463
1635
|
class LoginTokenResource extends mix(Resource).with(Creatable) {
|
|
1464
1636
|
constructor(client) {
|
|
1465
1637
|
super('login_tokens', Object, client);
|
|
@@ -1746,12 +1918,15 @@ class Cuenca {
|
|
|
1746
1918
|
this.apiKeys = new ApiKeyResource(client);
|
|
1747
1919
|
this.balanceEntries = new BalanceEntryResource(client);
|
|
1748
1920
|
this.billPayments = new BillPaymentResource(client);
|
|
1921
|
+
this.bridgeAccounts = new BridegAccountResource(client);
|
|
1749
1922
|
this.cardActivations = new CardActivationResource(client);
|
|
1750
1923
|
this.cards = new CardResource(client);
|
|
1751
1924
|
this.cardTransactions = new CardTransactionResource(client);
|
|
1752
1925
|
this.cardValidations = new CardValidationResource(client);
|
|
1753
1926
|
this.commissions = new CommissionResource(client);
|
|
1754
1927
|
this.deposits = new DepositResource(client);
|
|
1928
|
+
this.files = new FileResource(client);
|
|
1929
|
+
this.kycValidations = new KYCValidationsResource(client);
|
|
1755
1930
|
this.loginTokens = new LoginTokenResource(client);
|
|
1756
1931
|
this.savings = new SavingResource(client);
|
|
1757
1932
|
this.serviceProviders = new ServiceProviderResource(client);
|