@cuenca-mx/cuenca-js 0.0.5-dev.1 → 0.0.5-dev.11
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-86ddd935.mjs} +5 -3
- package/build/{data-6451748e.cjs → data-d25afb50.cjs} +5 -3
- package/build/{identities-cd77b9f2.cjs → identities-b472f1c7.cjs} +25 -3
- package/build/{identities-c0047807.mjs → identities-f01f7ffa.mjs} +25 -3
- package/build/index.cjs +118 -12
- package/build/index.mjs +118 -12
- package/build/requests/index.cjs +5 -2
- package/build/requests/index.mjs +3 -2
- package/build/types/index.cjs +2 -2
- package/build/types/index.mjs +2 -2
- package/build/umd/cuenca.umd.js +1 -1
- package/build/{walletTransactionRequest-2e5deaee.mjs → walletTransactionRequest-1a351e54.mjs} +112 -2
- package/build/{walletTransactionRequest-267a5d18.cjs → walletTransactionRequest-7b37acb9.cjs} +113 -1
- package/package.json +3 -2
|
@@ -125,11 +125,13 @@ class EntryType {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
class FileFormat {
|
|
128
|
-
static Pdf = new FileFormat('pdf');
|
|
128
|
+
static Pdf = new FileFormat('application/pdf');
|
|
129
129
|
|
|
130
|
-
static Xml = new FileFormat('xml');
|
|
130
|
+
static Xml = new FileFormat('application/xml');
|
|
131
131
|
|
|
132
|
-
static Json = new FileFormat('json');
|
|
132
|
+
static Json = new FileFormat('application/json');
|
|
133
|
+
|
|
134
|
+
static Any = new FileFormat('*/*');
|
|
133
135
|
|
|
134
136
|
constructor(value) {
|
|
135
137
|
this.value = value;
|
|
@@ -127,11 +127,13 @@ class EntryType {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
class FileFormat {
|
|
130
|
-
static Pdf = new FileFormat('pdf');
|
|
130
|
+
static Pdf = new FileFormat('application/pdf');
|
|
131
131
|
|
|
132
|
-
static Xml = new FileFormat('xml');
|
|
132
|
+
static Xml = new FileFormat('application/xml');
|
|
133
133
|
|
|
134
|
-
static Json = new FileFormat('json');
|
|
134
|
+
static Json = new FileFormat('application/json');
|
|
135
|
+
|
|
136
|
+
static Any = new FileFormat('*/*');
|
|
135
137
|
|
|
136
138
|
constructor(value) {
|
|
137
139
|
this.value = value;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var errors_index = require('./errors/index.cjs');
|
|
4
|
-
var data = require('./data-
|
|
4
|
+
var data = require('./data-d25afb50.cjs');
|
|
5
5
|
|
|
6
6
|
class PageSize {
|
|
7
7
|
constructor(size) {
|
|
@@ -315,19 +315,41 @@ class TOSAgreements {
|
|
|
315
315
|
});
|
|
316
316
|
}
|
|
317
317
|
|
|
318
|
+
class VerificationError {
|
|
319
|
+
constructor({ code, error, identifier, message }) {
|
|
320
|
+
this.code = code;
|
|
321
|
+
this.error = error;
|
|
322
|
+
this.identifier = identifier;
|
|
323
|
+
this.message = message;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
static fromObject = ({ code, error, identifier, message }) =>
|
|
327
|
+
new VerificationError({
|
|
328
|
+
code,
|
|
329
|
+
error,
|
|
330
|
+
identifier,
|
|
331
|
+
message,
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
|
|
318
335
|
class KYCFile {
|
|
319
|
-
constructor({ data: data$1, isMx, status, type, uriBack, uriFront }) {
|
|
336
|
+
constructor({ data: data$1, errors, isMx, status, type, uriBack, uriFront }) {
|
|
320
337
|
this.data = data$1;
|
|
321
338
|
this.isMx = isMx;
|
|
322
339
|
this.status = data.enumValueFromString(data.KYCStatus, status);
|
|
323
340
|
this.type = data.enumValueFromString(data.KYCFileType, type);
|
|
324
341
|
this.uriBack = uriBack;
|
|
325
342
|
this.uriFront = uriFront;
|
|
343
|
+
|
|
344
|
+
if (errors && errors.length > 0) {
|
|
345
|
+
this.errors = errors.map((e) => VerificationError.fromObject(e));
|
|
346
|
+
}
|
|
326
347
|
}
|
|
327
348
|
|
|
328
|
-
static fromObject = ({ data, status, type, ...obj }) =>
|
|
349
|
+
static fromObject = ({ data, errors, status, type, ...obj }) =>
|
|
329
350
|
new KYCFile({
|
|
330
351
|
data,
|
|
352
|
+
errors,
|
|
331
353
|
status,
|
|
332
354
|
type,
|
|
333
355
|
isMx: obj.is_mx,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ValidationError } from './errors/index.mjs';
|
|
2
|
-
import { d as dateToUTC, e as enumValueFromString,
|
|
2
|
+
import { d as dateToUTC, e as enumValueFromString, l as KYCStatus, K as KYCFileType } from './data-86ddd935.mjs';
|
|
3
3
|
|
|
4
4
|
class PageSize {
|
|
5
5
|
constructor(size) {
|
|
@@ -313,19 +313,41 @@ class TOSAgreements {
|
|
|
313
313
|
});
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
+
class VerificationError {
|
|
317
|
+
constructor({ code, error, identifier, message }) {
|
|
318
|
+
this.code = code;
|
|
319
|
+
this.error = error;
|
|
320
|
+
this.identifier = identifier;
|
|
321
|
+
this.message = message;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
static fromObject = ({ code, error, identifier, message }) =>
|
|
325
|
+
new VerificationError({
|
|
326
|
+
code,
|
|
327
|
+
error,
|
|
328
|
+
identifier,
|
|
329
|
+
message,
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
|
|
316
333
|
class KYCFile {
|
|
317
|
-
constructor({ data, isMx, status, type, uriBack, uriFront }) {
|
|
334
|
+
constructor({ data, errors, isMx, status, type, uriBack, uriFront }) {
|
|
318
335
|
this.data = data;
|
|
319
336
|
this.isMx = isMx;
|
|
320
337
|
this.status = enumValueFromString(KYCStatus, status);
|
|
321
338
|
this.type = enumValueFromString(KYCFileType, type);
|
|
322
339
|
this.uriBack = uriBack;
|
|
323
340
|
this.uriFront = uriFront;
|
|
341
|
+
|
|
342
|
+
if (errors && errors.length > 0) {
|
|
343
|
+
this.errors = errors.map((e) => VerificationError.fromObject(e));
|
|
344
|
+
}
|
|
324
345
|
}
|
|
325
346
|
|
|
326
|
-
static fromObject = ({ data, status, type, ...obj }) =>
|
|
347
|
+
static fromObject = ({ data, errors, status, type, ...obj }) =>
|
|
327
348
|
new KYCFile({
|
|
328
349
|
data,
|
|
350
|
+
errors,
|
|
329
351
|
status,
|
|
330
352
|
type,
|
|
331
353
|
isMx: obj.is_mx,
|
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-d25afb50.cjs');
|
|
10
|
+
var identities = require('./identities-b472f1c7.cjs');
|
|
11
|
+
var walletTransactionRequest = require('./walletTransactionRequest-7b37acb9.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-dev.
|
|
30
|
+
const name="@cuenca-mx/cuenca-js";const version="0.0.5-dev.11";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();
|
|
@@ -628,6 +634,35 @@ class Deposit extends Transaction {
|
|
|
628
634
|
});
|
|
629
635
|
}
|
|
630
636
|
|
|
637
|
+
class File {
|
|
638
|
+
constructor({ extension, type, url, userId }) {
|
|
639
|
+
this.extension = extension;
|
|
640
|
+
this.type = data.enumValueFromString(data.KYCFileType, type);
|
|
641
|
+
this.url = url;
|
|
642
|
+
this.userId = userId;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
static fromObject = ({ extension, type, url, ...obj }) =>
|
|
646
|
+
new File({ extension, type, url, userId: obj.user_id });
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
class KYCValidations {
|
|
650
|
+
constructor({ platformId, attemps, verificationId, filesUri }) {
|
|
651
|
+
this.attemps = attemps;
|
|
652
|
+
this.filesUri = filesUri;
|
|
653
|
+
this.platformId = platformId;
|
|
654
|
+
this.verificationId = verificationId;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
static fromObject = ({ attemps, ...obj }) =>
|
|
658
|
+
new KYCValidations({
|
|
659
|
+
attemps,
|
|
660
|
+
filesUri: obj.files_uri,
|
|
661
|
+
platformId: obj.platform_id,
|
|
662
|
+
verificationId: obj.verification_id,
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
|
|
631
666
|
class LoginToken {
|
|
632
667
|
constructor({ id }) {
|
|
633
668
|
this.id = id;
|
|
@@ -786,20 +821,25 @@ class User {
|
|
|
786
821
|
address,
|
|
787
822
|
blacklistValidationStatus,
|
|
788
823
|
clabe,
|
|
824
|
+
countryOfBirth,
|
|
789
825
|
createdAt,
|
|
790
826
|
curp,
|
|
827
|
+
dateOfBirth,
|
|
791
828
|
emailAddress,
|
|
792
829
|
firstSurname,
|
|
830
|
+
gender,
|
|
793
831
|
govtId,
|
|
794
832
|
id,
|
|
795
833
|
level,
|
|
796
834
|
names,
|
|
835
|
+
nationality,
|
|
797
836
|
phoneNumber,
|
|
798
837
|
proofOfAddress,
|
|
799
838
|
proofOfLife,
|
|
800
839
|
requiredLevel,
|
|
801
840
|
rfc,
|
|
802
841
|
secondSurname,
|
|
842
|
+
stateOfBirth,
|
|
803
843
|
status,
|
|
804
844
|
termsOfService,
|
|
805
845
|
updatedAt,
|
|
@@ -811,20 +851,25 @@ class User {
|
|
|
811
851
|
blacklistValidationStatus,
|
|
812
852
|
);
|
|
813
853
|
this.clabe = clabe;
|
|
854
|
+
this.countryOfBirth = countryOfBirth;
|
|
814
855
|
this.createdAt = data.dateToUTC(createdAt);
|
|
815
856
|
this.curp = curp;
|
|
857
|
+
this.dateOfBirth = dateOfBirth;
|
|
816
858
|
this.emailAddress = emailAddress;
|
|
817
859
|
this.firstSurname = firstSurname;
|
|
860
|
+
this.gender = gender;
|
|
818
861
|
this.govstIds = govtId;
|
|
819
862
|
this.id = id;
|
|
820
863
|
this.level = level;
|
|
821
864
|
this.names = names;
|
|
865
|
+
this.nationality = nationality;
|
|
822
866
|
this.phoneNumber = phoneNumber;
|
|
823
867
|
this.addressProofs = proofOfAddress;
|
|
824
868
|
this.lifeProofs = proofOfLife;
|
|
825
869
|
this.requiredLevel = requiredLevel;
|
|
826
870
|
this.rfc = rfc;
|
|
827
871
|
this.secondSurname = secondSurname;
|
|
872
|
+
this.stateOfBirth = stateOfBirth;
|
|
828
873
|
this.status = data.enumValueFromString(data.UserStatus, status);
|
|
829
874
|
this.terms = termsOfService;
|
|
830
875
|
this.updatedAt = data.dateToUTC(updatedAt);
|
|
@@ -880,9 +925,11 @@ class User {
|
|
|
880
925
|
address,
|
|
881
926
|
clabe,
|
|
882
927
|
curp,
|
|
928
|
+
gender,
|
|
883
929
|
id,
|
|
884
930
|
level,
|
|
885
931
|
names,
|
|
932
|
+
nationality,
|
|
886
933
|
rfc,
|
|
887
934
|
status,
|
|
888
935
|
...obj
|
|
@@ -891,13 +938,17 @@ class User {
|
|
|
891
938
|
address,
|
|
892
939
|
clabe,
|
|
893
940
|
curp,
|
|
941
|
+
gender,
|
|
894
942
|
id,
|
|
895
943
|
level,
|
|
896
944
|
names,
|
|
945
|
+
nationality,
|
|
897
946
|
rfc,
|
|
898
947
|
status,
|
|
899
948
|
blacklistValidationStatus: obj.blacklist_validation_status,
|
|
949
|
+
countryOfBirth: obj.country_of_birth,
|
|
900
950
|
createdAt: obj.created_at,
|
|
951
|
+
dateOfBirth: obj.date_of_birth,
|
|
901
952
|
emailAddress: obj.email_address,
|
|
902
953
|
firstSurname: obj.first_surname,
|
|
903
954
|
govtId: obj.govt_id,
|
|
@@ -906,6 +957,7 @@ class User {
|
|
|
906
957
|
proofOfLife: obj.proof_of_life,
|
|
907
958
|
requiredLevel: obj.required_level,
|
|
908
959
|
secondSurname: obj.second_surname,
|
|
960
|
+
stateOfBirth: obj.state_of_birth,
|
|
909
961
|
termsOfService: obj.terms_of_service,
|
|
910
962
|
updatedAt: obj.updated_at,
|
|
911
963
|
verificationId: obj.verification_id,
|
|
@@ -1083,6 +1135,8 @@ const getModelFromPath = (path, obj) => {
|
|
|
1083
1135
|
card_validations: () => CardValidation.fromObject(obj),
|
|
1084
1136
|
commissions: () => Commission.fromObject(obj),
|
|
1085
1137
|
deposits: () => Deposit.fromObject(obj),
|
|
1138
|
+
files: () => File.fromObject(obj),
|
|
1139
|
+
kyc_validations: () => KYCValidations.fromObject(obj),
|
|
1086
1140
|
login_tokens: () => LoginToken.fromObject(obj),
|
|
1087
1141
|
savings: () => Saving.fromObject(obj),
|
|
1088
1142
|
service_providers: () => ServiceProvider.fromObject(obj),
|
|
@@ -1148,6 +1202,19 @@ const Updateable = (SuperClass) =>
|
|
|
1148
1202
|
}
|
|
1149
1203
|
};
|
|
1150
1204
|
|
|
1205
|
+
const Uploadable = (SuperClass) =>
|
|
1206
|
+
class Uploadable extends SuperClass {
|
|
1207
|
+
async _upload(data) {
|
|
1208
|
+
const response = await this.client.post({
|
|
1209
|
+
endpoint: `/${this.path}`,
|
|
1210
|
+
data,
|
|
1211
|
+
multipart: true,
|
|
1212
|
+
});
|
|
1213
|
+
const model = getModelFromPath(this.path, response);
|
|
1214
|
+
return model;
|
|
1215
|
+
}
|
|
1216
|
+
};
|
|
1217
|
+
|
|
1151
1218
|
const Deactivable = (SuperClass) =>
|
|
1152
1219
|
class Deactivable extends SuperClass {
|
|
1153
1220
|
async _deactivate(id, data) {
|
|
@@ -1163,10 +1230,14 @@ const Deactivable = (SuperClass) =>
|
|
|
1163
1230
|
const Downlodable = (SuperClass) =>
|
|
1164
1231
|
class Downlodable extends SuperClass {
|
|
1165
1232
|
async _download(id, format) {
|
|
1233
|
+
const interceptor = this.client.addConfigToRequest({
|
|
1234
|
+
responseType: 'stream',
|
|
1235
|
+
});
|
|
1166
1236
|
const byteString = await this.client.get({
|
|
1167
1237
|
endpoint: `/${this.path}/${id}`,
|
|
1168
1238
|
format,
|
|
1169
1239
|
});
|
|
1240
|
+
interceptor.eject();
|
|
1170
1241
|
return byteString;
|
|
1171
1242
|
}
|
|
1172
1243
|
};
|
|
@@ -1460,6 +1531,39 @@ class DepositResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
|
1460
1531
|
}
|
|
1461
1532
|
}
|
|
1462
1533
|
|
|
1534
|
+
class FileResource extends mix(Resource).with(Downlodable, Uploadable) {
|
|
1535
|
+
constructor(client) {
|
|
1536
|
+
super('files', Object, client);
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
async download(id) {
|
|
1540
|
+
const byteString = await this._download(id, data.FileFormat.Any);
|
|
1541
|
+
return byteString;
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
async upload({ ...req }) {
|
|
1545
|
+
const request = new walletTransactionRequest.UploadRequest(req);
|
|
1546
|
+
const fileUpload = await this._upload(request.toFormData());
|
|
1547
|
+
return fileUpload;
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
class KYCValidationsResource extends mix(Resource).with(
|
|
1552
|
+
Creatable,
|
|
1553
|
+
Retrievable,
|
|
1554
|
+
Queryable,
|
|
1555
|
+
) {
|
|
1556
|
+
constructor(client) {
|
|
1557
|
+
super('kyc_validations', Object, client);
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
async create(userId = 'me') {
|
|
1561
|
+
const request = new walletTransactionRequest.KYCValidationsRequest(userId);
|
|
1562
|
+
const kycValidation = await this._create(request.toObject());
|
|
1563
|
+
return kycValidation;
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1463
1567
|
class LoginTokenResource extends mix(Resource).with(Creatable) {
|
|
1464
1568
|
constructor(client) {
|
|
1465
1569
|
super('login_tokens', Object, client);
|
|
@@ -1752,6 +1856,8 @@ class Cuenca {
|
|
|
1752
1856
|
this.cardValidations = new CardValidationResource(client);
|
|
1753
1857
|
this.commissions = new CommissionResource(client);
|
|
1754
1858
|
this.deposits = new DepositResource(client);
|
|
1859
|
+
this.files = new FileResource(client);
|
|
1860
|
+
this.kycValidations = new KYCValidationsResource(client);
|
|
1755
1861
|
this.loginTokens = new LoginTokenResource(client);
|
|
1756
1862
|
this.savings = new SavingResource(client);
|
|
1757
1863
|
this.serviceProviders = new ServiceProviderResource(client);
|