@cuenca-mx/cuenca-js 0.0.1-dev.4 → 0.0.1-dev.42
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/errors/index.mjs +64 -0
- package/build/identities-5e48f342.mjs +337 -0
- package/build/identities-93faf1ed.cjs +354 -0
- package/build/{index.js → index.cjs} +288 -98
- package/build/index.mjs +1699 -0
- package/build/jwt/index.cjs +55 -0
- package/build/jwt/{index.js → index.mjs} +5 -8
- package/build/requests/{index.js → index.cjs} +6 -3
- package/build/requests/index.mjs +3 -0
- package/build/types/index.cjs +47 -0
- package/build/types/index.mjs +3 -0
- package/build/umd/cuenca.umd.js +1 -1
- package/build/{walletTransactionRequest-17132eb5.js → walletTransactionRequest-3b0c406d.mjs} +128 -5
- package/build/{walletTransactionRequest-b588cc52.js → walletTransactionRequest-832088b1.cjs} +130 -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-395c7467.js +0 -546
- package/build/types/index.js +0 -40
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var errors_index = require('./errors/index.js');
|
|
4
|
-
var data = require('./data-c53f1052.js');
|
|
5
|
-
|
|
6
3
|
class CardErrorType {
|
|
7
4
|
static Blocked = new CardErrorType('blocked');
|
|
8
5
|
|
|
@@ -141,6 +138,38 @@ class FileFormat {
|
|
|
141
138
|
}
|
|
142
139
|
}
|
|
143
140
|
|
|
141
|
+
class KYCFileType {
|
|
142
|
+
static Ine = new KYCFileType('ine');
|
|
143
|
+
|
|
144
|
+
static Passport = new KYCFileType('passport');
|
|
145
|
+
|
|
146
|
+
static Residency = new KYCFileType('residency');
|
|
147
|
+
|
|
148
|
+
static MatriculaConsular = new KYCFileType('matricula_consular');
|
|
149
|
+
|
|
150
|
+
static ProofOfLiveness = new KYCFileType('proof_of_liveness');
|
|
151
|
+
|
|
152
|
+
static ProofOfAddress = new KYCFileType('proof_of_address');
|
|
153
|
+
|
|
154
|
+
constructor(value) {
|
|
155
|
+
this.value = value;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
class KYCStatus {
|
|
160
|
+
static UploadAgain = new KYCStatus('upload_again');
|
|
161
|
+
|
|
162
|
+
static ReviewNeeded = new KYCStatus('review_needed');
|
|
163
|
+
|
|
164
|
+
static Submitted = new KYCStatus('submitted');
|
|
165
|
+
|
|
166
|
+
static Succeeded = new KYCStatus('succeeded');
|
|
167
|
+
|
|
168
|
+
constructor(value) {
|
|
169
|
+
this.value = value;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
144
173
|
class Phase {
|
|
145
174
|
static Sandbox = new Phase('sandbox');
|
|
146
175
|
|
|
@@ -257,321 +286,69 @@ class TransferNetwork {
|
|
|
257
286
|
}
|
|
258
287
|
}
|
|
259
288
|
|
|
260
|
-
class
|
|
261
|
-
static
|
|
262
|
-
|
|
263
|
-
static Withdrawal = new WalletTransactionType('withdrawal');
|
|
264
|
-
|
|
265
|
-
constructor(value) {
|
|
266
|
-
this.value = value;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
class PageSize {
|
|
271
|
-
constructor(size) {
|
|
272
|
-
this.maxSize = 100;
|
|
273
|
-
this._ps = size;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
get size() {
|
|
277
|
-
return this._pageSize;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
set _ps(value) {
|
|
281
|
-
let validatedPageSize = this.maxSize;
|
|
282
|
-
if (value && value > 0 && value <= this.maxSize) {
|
|
283
|
-
validatedPageSize = value;
|
|
284
|
-
}
|
|
285
|
-
this._pageSize = validatedPageSize;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
class QueryParams {
|
|
290
|
-
constructor({
|
|
291
|
-
createdAfter,
|
|
292
|
-
createdBefore,
|
|
293
|
-
limit,
|
|
294
|
-
pageSize,
|
|
295
|
-
relatedTransaction,
|
|
296
|
-
userId,
|
|
297
|
-
count = false,
|
|
298
|
-
}) {
|
|
299
|
-
this.createdAfter = createdAfter;
|
|
300
|
-
this.createdBefore = createdBefore;
|
|
301
|
-
this._lmt = limit;
|
|
302
|
-
this.relatedTransaction = relatedTransaction;
|
|
303
|
-
this.userId = userId;
|
|
304
|
-
this.count = count;
|
|
305
|
-
this.pageSize = pageSize;
|
|
306
|
-
}
|
|
289
|
+
class UserStatus {
|
|
290
|
+
static Active = new UserStatus('active');
|
|
307
291
|
|
|
308
|
-
|
|
309
|
-
return this._limit;
|
|
310
|
-
}
|
|
292
|
+
static Deactivated = new UserStatus('deactivated');
|
|
311
293
|
|
|
312
|
-
|
|
313
|
-
set _lmt(value) {
|
|
314
|
-
let validatedValue = null;
|
|
315
|
-
if (value && value >= 0) {
|
|
316
|
-
validatedValue = value;
|
|
317
|
-
}
|
|
318
|
-
this._limit = validatedValue;
|
|
319
|
-
}
|
|
294
|
+
static Fraud = new UserStatus('fraud');
|
|
320
295
|
|
|
321
|
-
|
|
322
|
-
return {
|
|
323
|
-
created_after: this.createdAfter,
|
|
324
|
-
created_before: this.createdBefore,
|
|
325
|
-
limit: this.limit,
|
|
326
|
-
related_transaction: this.relatedTransaction,
|
|
327
|
-
user_id: this.userId,
|
|
328
|
-
page_size: this.pageSize && this.pageSize.size,
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
toParams() {
|
|
333
|
-
const helper = { ...this.toObject() };
|
|
334
|
-
if (this.count) helper.count = 1;
|
|
335
|
-
Object.keys(helper).forEach((k) => {
|
|
336
|
-
if (helper[k] == null) delete helper[k];
|
|
337
|
-
});
|
|
338
|
-
return helper;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
toQueryString() {
|
|
342
|
-
return new URLSearchParams(this.toParams()).toString();
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
class AccountQuery extends QueryParams {
|
|
347
|
-
constructor({ accountNumber, ...args }) {
|
|
348
|
-
super(args);
|
|
349
|
-
this.accountNumber = accountNumber;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
toObject() {
|
|
353
|
-
return Object.assign(super.toObject(), {
|
|
354
|
-
account_number: this.accountNumber,
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
class ApiKeyQuery extends QueryParams {
|
|
360
|
-
constructor({ active, ...args }) {
|
|
361
|
-
super(args);
|
|
362
|
-
this.active = active;
|
|
363
|
-
}
|
|
296
|
+
static PldBlocked = new UserStatus('pld_blocked');
|
|
364
297
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
active: this.active,
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
class TransactionQuery extends QueryParams {
|
|
373
|
-
constructor({ status, ...args }) {
|
|
374
|
-
super(args);
|
|
375
|
-
this.status = status;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
toObject() {
|
|
379
|
-
return Object.assign(super.toObject(), {
|
|
380
|
-
status: this.status,
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
class DepositQuery extends TransactionQuery {
|
|
386
|
-
constructor({ trackingKey, network, ...args }) {
|
|
387
|
-
super(args);
|
|
388
|
-
this.trackingKey = trackingKey;
|
|
389
|
-
this.network = network;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
toObject() {
|
|
393
|
-
return Object.assign(super.toObject(), {
|
|
394
|
-
tracking_key: this.trackingKey,
|
|
395
|
-
network: this.network,
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
class TransferQuery extends TransactionQuery {
|
|
401
|
-
constructor({
|
|
402
|
-
accountNumber,
|
|
403
|
-
idempotencyKey,
|
|
404
|
-
trackingKey,
|
|
405
|
-
network,
|
|
406
|
-
...args
|
|
407
|
-
}) {
|
|
408
|
-
super(args);
|
|
409
|
-
this.accountNumber = accountNumber;
|
|
410
|
-
this.idempotencyKey = idempotencyKey;
|
|
411
|
-
this.trackingKey = trackingKey;
|
|
412
|
-
this.network = network;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
toObject() {
|
|
416
|
-
return Object.assign(super.toObject(), {
|
|
417
|
-
account_number: this.accountNumber,
|
|
418
|
-
idempotency_key: this.idempotencyKey,
|
|
419
|
-
tracking_key: this.trackingKey,
|
|
420
|
-
network: this.network,
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
class BalanceEntryQuery extends QueryParams {
|
|
426
|
-
constructor({
|
|
427
|
-
fundingInstrumentUri,
|
|
428
|
-
count = false,
|
|
429
|
-
walletId = 'default',
|
|
430
|
-
...args
|
|
431
|
-
}) {
|
|
432
|
-
super(args);
|
|
433
|
-
this.fundingInstrumentUri = fundingInstrumentUri;
|
|
434
|
-
this.count = count;
|
|
435
|
-
this.walletId = walletId;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
toObject() {
|
|
439
|
-
return Object.assign(super.toObject(), {
|
|
440
|
-
wallet_id: this.walletId,
|
|
441
|
-
funding_instrument_uri: this.fundingInstrumentUri,
|
|
442
|
-
count: this.count,
|
|
443
|
-
});
|
|
298
|
+
constructor(value) {
|
|
299
|
+
this.value = value;
|
|
444
300
|
}
|
|
445
301
|
}
|
|
446
302
|
|
|
447
|
-
class
|
|
448
|
-
|
|
449
|
-
super(args);
|
|
450
|
-
this.accountNumber = accountNumber;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
toObject() {
|
|
454
|
-
return Object.assign(super.toObject(), {
|
|
455
|
-
account_number: this.accountNumber,
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
}
|
|
303
|
+
class VerificationType {
|
|
304
|
+
static Phone = new VerificationType('phone');
|
|
459
305
|
|
|
460
|
-
|
|
461
|
-
constructor({ cardUri, ...args }) {
|
|
462
|
-
super(args);
|
|
463
|
-
this.cardUri = cardUri;
|
|
464
|
-
}
|
|
306
|
+
static Email = new VerificationType('email');
|
|
465
307
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
card_uri: this.cardUri,
|
|
469
|
-
});
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
class CardsQuery extends QueryParams {
|
|
474
|
-
constructor({ cardUri, count = false, ...args }) {
|
|
475
|
-
super(args);
|
|
476
|
-
this.cardUri = cardUri;
|
|
477
|
-
this.count = count;
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
toObject() {
|
|
481
|
-
return Object.assign(super.toObject(), {
|
|
482
|
-
card_uri: this.cardUri,
|
|
483
|
-
count: this.count,
|
|
484
|
-
});
|
|
308
|
+
constructor(value) {
|
|
309
|
+
this.value = value;
|
|
485
310
|
}
|
|
486
311
|
}
|
|
487
312
|
|
|
488
|
-
class
|
|
489
|
-
|
|
490
|
-
super(args);
|
|
491
|
-
this.walletUri = walletUri;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
toObject() {
|
|
495
|
-
return Object.assign(super.toObject(), {
|
|
496
|
-
wallet_uri: this.walletUri,
|
|
497
|
-
});
|
|
498
|
-
}
|
|
499
|
-
}
|
|
313
|
+
class WalletTransactionType {
|
|
314
|
+
static Deposit = new WalletTransactionType('deposit');
|
|
500
315
|
|
|
501
|
-
|
|
502
|
-
constructor({ active, ...args }) {
|
|
503
|
-
super(args);
|
|
504
|
-
this.active = active;
|
|
505
|
-
}
|
|
316
|
+
static Withdrawal = new WalletTransactionType('withdrawal');
|
|
506
317
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
active: this.active,
|
|
510
|
-
});
|
|
318
|
+
constructor(value) {
|
|
319
|
+
this.value = value;
|
|
511
320
|
}
|
|
512
321
|
}
|
|
513
322
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
get month() {
|
|
521
|
-
return this._date.month;
|
|
522
|
-
}
|
|
323
|
+
const dateToUTC = (date) => {
|
|
324
|
+
if (!date) return null;
|
|
325
|
+
const dateObj = new Date(date);
|
|
326
|
+
return new Date(dateObj.getTime());
|
|
327
|
+
};
|
|
523
328
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
set d({ month, year }) {
|
|
529
|
-
const now = data.dateToUTC(Date.now());
|
|
530
|
-
now.setUTCDate(1);
|
|
531
|
-
const date = data.dateToUTC(`${year}-${month}-01`);
|
|
532
|
-
if (date.getTime() >= now.getTime()) {
|
|
533
|
-
throw new errors_index.ValidationError(
|
|
534
|
-
`${year}-${month} is not a valid year-month pair`,
|
|
535
|
-
);
|
|
536
|
-
}
|
|
537
|
-
this._date = { month, year };
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
toObject() {
|
|
541
|
-
return Object.assign(super.toObject(), {
|
|
542
|
-
month: this.month,
|
|
543
|
-
year: this.year,
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
}
|
|
329
|
+
const enumValueFromString = (enumValue, value) =>
|
|
330
|
+
Object.values(enumValue).find((enumV) => enumV.value === value);
|
|
547
331
|
|
|
548
|
-
exports.AccountQuery = AccountQuery;
|
|
549
|
-
exports.ApiKeyQuery = ApiKeyQuery;
|
|
550
|
-
exports.BalanceEntryQuery = BalanceEntryQuery;
|
|
551
|
-
exports.BillPaymentQuery = BillPaymentQuery;
|
|
552
332
|
exports.CardErrorType = CardErrorType;
|
|
553
333
|
exports.CardFundingType = CardFundingType;
|
|
554
334
|
exports.CardIssuer = CardIssuer;
|
|
555
335
|
exports.CardStatus = CardStatus;
|
|
556
|
-
exports.CardTransactionQuery = CardTransactionQuery;
|
|
557
336
|
exports.CardTransactionType = CardTransactionType;
|
|
558
337
|
exports.CardType = CardType;
|
|
559
|
-
exports.CardsQuery = CardsQuery;
|
|
560
338
|
exports.CommissionType = CommissionType;
|
|
561
339
|
exports.DepositNetwork = DepositNetwork;
|
|
562
|
-
exports.DepositQuery = DepositQuery;
|
|
563
340
|
exports.EntryType = EntryType;
|
|
564
341
|
exports.FileFormat = FileFormat;
|
|
565
|
-
exports.
|
|
342
|
+
exports.KYCFileType = KYCFileType;
|
|
343
|
+
exports.KYCStatus = KYCStatus;
|
|
566
344
|
exports.Phase = Phase;
|
|
567
|
-
exports.QueryParams = QueryParams;
|
|
568
345
|
exports.SavingCategory = SavingCategory;
|
|
569
346
|
exports.ServiceProviderCategory = ServiceProviderCategory;
|
|
570
|
-
exports.StatementQuery = StatementQuery;
|
|
571
347
|
exports.TrackDataMethod = TrackDataMethod;
|
|
572
348
|
exports.TransactionStatus = TransactionStatus;
|
|
573
349
|
exports.TransferNetwork = TransferNetwork;
|
|
574
|
-
exports.
|
|
575
|
-
exports.
|
|
576
|
-
exports.WalletTransactionQuery = WalletTransactionQuery;
|
|
350
|
+
exports.UserStatus = UserStatus;
|
|
351
|
+
exports.VerificationType = VerificationType;
|
|
577
352
|
exports.WalletTransactionType = WalletTransactionType;
|
|
353
|
+
exports.dateToUTC = dateToUTC;
|
|
354
|
+
exports.enumValueFromString = enumValueFromString;
|
|
File without changes
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
class CuencaException extends Error {
|
|
2
|
+
constructor(msg) {
|
|
3
|
+
super(msg);
|
|
4
|
+
|
|
5
|
+
Object.setPrototypeOf(this, CuencaException.prototype);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
class CuencaResponseException extends CuencaException {
|
|
10
|
+
constructor(data, status) {
|
|
11
|
+
super(`Cuenca Response Error: ${status}`);
|
|
12
|
+
this.name = 'CuencaResponseError';
|
|
13
|
+
this.data = data;
|
|
14
|
+
this.status = status;
|
|
15
|
+
|
|
16
|
+
Object.setPrototypeOf(this, CuencaResponseException.prototype);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
class NoResultFound extends CuencaException {
|
|
21
|
+
constructor() {
|
|
22
|
+
super('No results were found');
|
|
23
|
+
this.name = 'NoResultFound';
|
|
24
|
+
|
|
25
|
+
Object.setPrototypeOf(this, NoResultFound.prototype);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
class MultipleResultsFound extends CuencaException {
|
|
30
|
+
constructor() {
|
|
31
|
+
super('One result was expected but multiple were found');
|
|
32
|
+
this.name = 'MultipleResultsFound';
|
|
33
|
+
|
|
34
|
+
Object.setPrototypeOf(this, MultipleResultsFound.prototype);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
class MalformedJwtToken extends CuencaException {
|
|
39
|
+
constructor() {
|
|
40
|
+
super('An invalid JWT token was obtained during authentication');
|
|
41
|
+
this.name = 'MalformedJwtToken';
|
|
42
|
+
|
|
43
|
+
Object.setPrototypeOf(this, MalformedJwtToken.prototype);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
class InvalidPassword extends CuencaException {
|
|
48
|
+
constructor() {
|
|
49
|
+
super('Invalid password');
|
|
50
|
+
this.name = 'InvalidPassword';
|
|
51
|
+
|
|
52
|
+
Object.setPrototypeOf(this, InvalidPassword.prototype);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
class ValidationError extends Error {
|
|
57
|
+
constructor(msg) {
|
|
58
|
+
super(msg);
|
|
59
|
+
|
|
60
|
+
Object.setPrototypeOf(this, ValidationError.prototype);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { CuencaException, CuencaResponseException, InvalidPassword, MalformedJwtToken, MultipleResultsFound, NoResultFound, ValidationError };
|