@cuenca-mx/cuenca-js 0.0.1-dev.5 → 0.0.1-dev.52

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.
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var errors_index = require('./errors/index.js');
4
- var data = require('./data-c53f1052.js');
3
+ var errors_index = require('./errors/index.cjs');
4
+ var data = require('./data-efb53250.cjs');
5
5
 
6
6
  class BaseRequest {
7
7
  toObject() {
@@ -309,6 +309,87 @@ class CardValidationRequest extends BaseRequest {
309
309
  }
310
310
  }
311
311
 
312
+ class IdentitiesUploadRequest extends BaseRequest {
313
+ constructor({
314
+ address,
315
+ blacklistValidationStatus,
316
+ countryOfBirth,
317
+ createdAt,
318
+ curp,
319
+ dateOfBirth,
320
+ extension,
321
+ firstSurname,
322
+ gender,
323
+ govId,
324
+ id,
325
+ names,
326
+ nationality,
327
+ proofOfAddress,
328
+ proofOfLife,
329
+ rfc,
330
+ rfcDocument,
331
+ rfcFile,
332
+ secondSurname,
333
+ stateOfBirth,
334
+ status,
335
+ tosAgreement,
336
+ userId,
337
+ }) {
338
+ super();
339
+ this.address = address;
340
+ this.blacklistValidationStatus = blacklistValidationStatus;
341
+ this.countryOfBirth = countryOfBirth;
342
+ this.createdAt = createdAt;
343
+ this.curp = curp;
344
+ this.dateOfBirth = dateOfBirth;
345
+ this.extension = extension;
346
+ this.firstSurname = firstSurname;
347
+ this.gender = gender;
348
+ this.govId = govId;
349
+ this.id = id;
350
+ this.names = names;
351
+ this.nationality = nationality;
352
+ this.proofOfAddress = proofOfAddress;
353
+ this.proofOfLife = proofOfLife;
354
+ this.rfc = rfc;
355
+ this.rfcDocument = rfcDocument;
356
+ this.rfcFile = rfcFile;
357
+ this.secondSurname = secondSurname;
358
+ this.stateOfBirth = stateOfBirth;
359
+ this.status = status;
360
+ this.tosAgreement = tosAgreement;
361
+ this.userId = userId;
362
+ }
363
+
364
+ toObject() {
365
+ return {
366
+ address: this.address,
367
+ blacklist_validation_status: this.blacklistValidationStatus,
368
+ country_of_birth: this.countryOfBirth,
369
+ created_at: this.createdAt,
370
+ curp: this.curp,
371
+ date_of_birth: this.dateOfBirth,
372
+ extension: this.extension,
373
+ first_surname: this.first_surname,
374
+ gender: this.gender,
375
+ gov_id: this.govId,
376
+ id: this.id,
377
+ names: this.names,
378
+ nationality: this.nationality,
379
+ proof_of_address: this.proofOfAddress,
380
+ proof_of_life: this.proofOfLife,
381
+ rfc: this.rfc,
382
+ rfc_document: this.rfcDocument,
383
+ rfc_file: this.rfcFile,
384
+ second_surname: this.secondSurname,
385
+ state_of_birth: this.stateOfBirth,
386
+ status: this.status,
387
+ tos_agreement: this.tosAgreement,
388
+ user_id: this.userId,
389
+ };
390
+ }
391
+ }
392
+
312
393
  class SavingRequest extends BaseRequest {
313
394
  constructor(category, goalAmount, goalDate, name) {
314
395
  super();
@@ -380,7 +461,7 @@ class UserCredentialRequest extends BaseRequest {
380
461
  }
381
462
 
382
463
  set pwd(value) {
383
- const validations = [!!value, value.length === 6, /^\d{6}$/.test(value)];
464
+ const validations = [!!value, value.length >= 6];
384
465
  if (validations.some((x) => !x)) {
385
466
  throw new errors_index.ValidationError('Invalid password');
386
467
  }
@@ -418,7 +499,7 @@ class UserCredentialUpdateRequest extends BaseRequest {
418
499
  this._password = value;
419
500
  return;
420
501
  }
421
- const validations = [value.length === 6, /^\d{6}$/.test(value)];
502
+ const validations = [value.length >= 6];
422
503
  if (validations.some((x) => !x)) {
423
504
  throw new errors_index.ValidationError('Invalid password');
424
505
  }
@@ -467,6 +548,129 @@ class UserLoginRequest extends BaseRequest {
467
548
  }
468
549
  }
469
550
 
551
+ class TosUpdateRequest extends BaseRequest {
552
+ constructor({ ip, location, type, version }) {
553
+ super();
554
+ this.ipAddress = ip;
555
+ this.location = location;
556
+ this.type = type;
557
+ this.version = version;
558
+ }
559
+
560
+ get ip() {
561
+ return this._ip;
562
+ }
563
+
564
+ set ipAddress(value) {
565
+ if (!value) throw new errors_index.ValidationError('missing ip address');
566
+ const ipBlocks = value.split('.');
567
+ const blocks = ipBlocks.every((block) => {
568
+ return block >= 0 && block <= 255;
569
+ });
570
+ if (blocks) {
571
+ this._ip = value;
572
+ } else {
573
+ throw new errors_index.ValidationError('Invalid ip address');
574
+ }
575
+ }
576
+
577
+ toObject() {
578
+ return {
579
+ ip: this.ip,
580
+ location: this.location,
581
+ type: this.type,
582
+ version: this.version,
583
+ };
584
+ }
585
+ }
586
+
587
+ class UserUpdateRequest extends BaseRequest {
588
+ constructor({ termsOfService, verificationId }) {
589
+ super();
590
+ this.terms = termsOfService;
591
+ this.verificationId = verificationId;
592
+ }
593
+
594
+ get termsOfService() {
595
+ return this._termsOfService;
596
+ }
597
+
598
+ set terms(value) {
599
+ if (!value) return;
600
+ this._termsOfService = new TosUpdateRequest(value).toObject();
601
+ }
602
+
603
+ toObject() {
604
+ return {
605
+ terms_of_service: this.termsOfService,
606
+ verification_id: this.verificationId,
607
+ };
608
+ }
609
+ }
610
+
611
+ class VerificationRequest extends BaseRequest {
612
+ constructor({ platformId, recipient, type }) {
613
+ super();
614
+ this.platformId = platformId;
615
+ this.type = type;
616
+ this.recipients = recipient;
617
+ }
618
+
619
+ get recipient() {
620
+ return this._recipient;
621
+ }
622
+
623
+ set recipients(value) {
624
+ function validateEmail(email) {
625
+ return email.match(
626
+ /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
627
+ );
628
+ }
629
+
630
+ function validatePhone(phone) {
631
+ return phone.match(/^\+?[0-9]{10,15}$/);
632
+ }
633
+
634
+ switch (data.enumValueFromString(data.VerificationType, this.type)) {
635
+ case data.VerificationType.Email:
636
+ if (validateEmail(value)) {
637
+ this._recipient = value;
638
+ } else {
639
+ throw new errors_index.ValidationError('Invalid email address');
640
+ }
641
+ break;
642
+ case data.VerificationType.Phone:
643
+ if (validatePhone(value)) {
644
+ this._recipient = value;
645
+ } else {
646
+ throw new errors_index.ValidationError('Invalid Phone Number');
647
+ }
648
+ break;
649
+ }
650
+ }
651
+
652
+ toObject() {
653
+ return {
654
+ platform_id: this.platformId,
655
+ recipient: this.recipient,
656
+ type: this.type,
657
+ };
658
+ }
659
+ }
660
+
661
+ class VerificationAttemptRequest extends BaseRequest {
662
+ constructor({ code }) {
663
+ super();
664
+ this.code = code;
665
+ }
666
+
667
+ toObject() {
668
+ return {
669
+ code: this.code,
670
+ };
671
+ }
672
+ }
673
+
470
674
  class WalletTransactionRequest extends BaseRequest {
471
675
  constructor(amount, transactionType, walletUri) {
472
676
  super();
@@ -490,9 +694,13 @@ exports.CardActivationRequest = CardActivationRequest;
490
694
  exports.CardRequest = CardRequest;
491
695
  exports.CardUpdateRequest = CardUpdateRequest;
492
696
  exports.CardValidationRequest = CardValidationRequest;
697
+ exports.IdentitiesUploadRequest = IdentitiesUploadRequest;
493
698
  exports.SavingRequest = SavingRequest;
494
699
  exports.TransferRequest = TransferRequest;
495
700
  exports.UserCredentialRequest = UserCredentialRequest;
496
701
  exports.UserCredentialUpdateRequest = UserCredentialUpdateRequest;
497
702
  exports.UserLoginRequest = UserLoginRequest;
703
+ exports.UserUpdateRequest = UserUpdateRequest;
704
+ exports.VerificationAttemptRequest = VerificationAttemptRequest;
705
+ exports.VerificationRequest = VerificationRequest;
498
706
  exports.WalletTransactionRequest = WalletTransactionRequest;
package/package.json CHANGED
@@ -1,19 +1,34 @@
1
1
  {
2
2
  "name": "@cuenca-mx/cuenca-js",
3
- "version": "0.0.1-dev.5",
3
+ "version": "0.0.1-dev.52",
4
4
  "description": "Cuenca client for JS",
5
- "main": "./build/index.js",
5
+ "main": "./build/index.cjs",
6
6
  "module": "./build/index.mjs",
7
7
  "browser": "./build/umd/cuenca.umd.js",
8
8
  "files": [
9
9
  "build/**/*"
10
10
  ],
11
11
  "exports": {
12
- ".": "./build/index.mjs",
13
- "./errors/": "./build/errors/index.mjs",
14
- "./jwt/": "./build/jwt/index.mjs",
15
- "./requests/": "./build/requests/index.mjs",
16
- "./types/": "./build/types/index.mjs"
12
+ ".": {
13
+ "import": "./build/index.mjs",
14
+ "require": "./build/index.cjs"
15
+ },
16
+ "./errors": {
17
+ "import": "./build/errors/index.mjs",
18
+ "require": "./build/errors/index.cjs"
19
+ },
20
+ "./jwt": {
21
+ "import": "./build/jwt/index.mjs",
22
+ "require": "./build/jwt/index.cjs"
23
+ },
24
+ "./requests": {
25
+ "import": "./build/requests/index.mjs",
26
+ "require": "./build/requests/index.cjs"
27
+ },
28
+ "./types": {
29
+ "import": "./build/types/index.mjs",
30
+ "require": "./build/types/index.cjs"
31
+ }
17
32
  },
18
33
  "packageManager": "yarn@3.0.2",
19
34
  "type": "module",
@@ -31,20 +46,19 @@
31
46
  },
32
47
  "homepage": "https://cuenca.com",
33
48
  "scripts": {
34
- "build": "rm -rf build/ && yarn node ./scripts/rollup/rollup.cjs",
49
+ "build": "rm -rf build/ && yarn rollup --config",
35
50
  "test": "yarn node --experimental-vm-modules $(yarn bin jest)",
36
51
  "publish": "yarn build && yarn npm publish"
37
52
  },
38
53
  "devDependencies": {
39
- "@rollup/plugin-commonjs": "^21.0.1",
54
+ "@rollup/plugin-json": "^4.1.0",
40
55
  "@rollup/plugin-node-resolve": "^13.1.1",
41
- "chalk": "^4.1.2",
42
- "fs-extra": "^10.0.0",
43
56
  "jest": "^27.4.5",
44
57
  "rollup": "^2.61.1",
45
58
  "rollup-plugin-terser": "^7.0.2"
46
59
  },
47
60
  "dependencies": {
48
- "axios": "^0.24.0"
61
+ "axios": "^0.24.0",
62
+ "buffer": "^6.0.3"
49
63
  }
50
64
  }
package/build/README.md DELETED
@@ -1,7 +0,0 @@
1
- # cuenca-js &middot; [![codecov](https://codecov.io/gh/cuenca-mx/cuenca-js/branch/main/graph/badge.svg?token=SRY49Q0VrM)](https://codecov.io/gh/cuenca-mx/cuenca-js)
2
-
3
- `cuenca-js` is a Javascript library client to use Cuenca's services.
4
-
5
- ## Installation
6
-
7
- ## Documentation
@@ -1,11 +0,0 @@
1
- const dateToUTC = (date) => {
2
- if (!date) return null;
3
- const dateObj = new Date(date);
4
- return new Date(dateObj.getTime());
5
- };
6
-
7
- const enumValueFromString = (enumValue, value) => {
8
- return Object.values(enumValue).find((enumV) => enumV.value === value);
9
- };
10
-
11
- export { dateToUTC as d, enumValueFromString as e };
@@ -1,14 +0,0 @@
1
- 'use strict';
2
-
3
- const dateToUTC = (date) => {
4
- if (!date) return null;
5
- const dateObj = new Date(date);
6
- return new Date(dateObj.getTime());
7
- };
8
-
9
- const enumValueFromString = (enumValue, value) => {
10
- return Object.values(enumValue).find((enumV) => enumV.value === value);
11
- };
12
-
13
- exports.dateToUTC = dateToUTC;
14
- exports.enumValueFromString = enumValueFromString;
@@ -1,37 +0,0 @@
1
- {
2
- "name": "@cuenca-mx/cuenca-js",
3
- "version": "0.0.1-dev.5",
4
- "description": "Cuenca client for JS",
5
- "main": "./index.js",
6
- "module": "./index.mjs",
7
- "browser": "./umd/cuenca.umd.js",
8
- "files": [
9
- "build/**/*"
10
- ],
11
- "exports": {
12
- ".": "./build/index.mjs",
13
- "./errors/": "./build/errors/index.mjs",
14
- "./jwt/": "./build/jwt/index.mjs",
15
- "./requests/": "./build/requests/index.mjs",
16
- "./types/": "./build/types/index.mjs"
17
- },
18
- "packageManager": "yarn@3.0.2",
19
- "type": "module",
20
- "repository": {
21
- "type": "git",
22
- "url": "https://github.com/cuenca-mx/cuenca-js.git",
23
- "directory": "packages/cuenca-js"
24
- },
25
- "keywords": [
26
- "cuenca"
27
- ],
28
- "license": "MIT",
29
- "bugs": {
30
- "url": "https://github.com/cuenca-mx/cuenca-js/issues"
31
- },
32
- "homepage": "https://cuenca.com",
33
- "dependencies": {
34
- "axios": "^0.24.0"
35
- },
36
- "private": false
37
- }