@cuenca-mx/cuenca-js 0.0.1-dev.2 → 0.0.1-dev.6
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/README.md +7 -0
- package/build/{esm/data-7d3d5fcc.js → data-7d3d5fcc.js} +0 -0
- package/build/{cjs/data-c53f1052.js → data-c53f1052.js} +0 -0
- package/build/{cjs/errors.js → errors/index.js} +0 -0
- package/build/{esm/errors.js → errors/index.mjs} +0 -0
- package/build/{cjs/index.js → index.js} +20 -20
- package/build/{esm/index.js → index.mjs} +7 -7
- package/build/{cjs/jwt.js → jwt/index.js} +2 -2
- package/build/{esm/jwt.js → jwt/index.mjs} +1 -1
- package/build/package.json +37 -0
- package/build/{cjs/queries-08df635b.js → queries-b8f29837.js} +2 -2
- package/build/{esm/queries-716c6be4.js → queries-f146b91b.js} +1 -1
- package/build/{cjs/requests.js → requests/index.js} +3 -3
- package/build/{esm/requests.js → requests/index.mjs} +3 -3
- package/build/{cjs/types.js → types/index.js} +3 -3
- package/build/{esm/types.js → types/index.mjs} +3 -3
- package/build/{cjs/walletTransactionRequest-82837ee6.js → walletTransactionRequest-b588cc52.js} +18 -18
- package/build/{esm/walletTransactionRequest-18aad4dc.js → walletTransactionRequest-bbfb87bd.js} +1 -1
- package/package.json +13 -4
package/build/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# cuenca-js · [](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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var axios = require('axios');
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var queries = require('./queries-
|
|
6
|
+
var errors_index = require('./errors/index.js');
|
|
7
|
+
var jwt_index = require('./jwt/index.js');
|
|
8
|
+
var queries = require('./queries-b8f29837.js');
|
|
9
9
|
var data = require('./data-c53f1052.js');
|
|
10
|
-
var walletTransactionRequest = require('./walletTransactionRequest-
|
|
10
|
+
var walletTransactionRequest = require('./walletTransactionRequest-b588cc52.js');
|
|
11
11
|
|
|
12
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
13
|
|
|
@@ -87,7 +87,7 @@ class Client {
|
|
|
87
87
|
|
|
88
88
|
if (phase) this.phase = phase;
|
|
89
89
|
|
|
90
|
-
if (useJwt) this.jwtToken = await
|
|
90
|
+
if (useJwt) this.jwtToken = await jwt_index.Jwt.create(this);
|
|
91
91
|
|
|
92
92
|
if (loginToken) {
|
|
93
93
|
this.addHeadersToRequest({ 'X-Cuenca-LoginToken': loginToken });
|
|
@@ -126,7 +126,7 @@ class Client {
|
|
|
126
126
|
|
|
127
127
|
if (this.jwtToken) {
|
|
128
128
|
if (this.jwtToken.isExpired) {
|
|
129
|
-
this.jwtToken = await
|
|
129
|
+
this.jwtToken = await jwt_index.Jwt.create(this);
|
|
130
130
|
}
|
|
131
131
|
headers['X-Cuenca-Token'] = this.jwtToken.token;
|
|
132
132
|
}
|
|
@@ -154,16 +154,16 @@ class Client {
|
|
|
154
154
|
response = await this._session.request({ baseURL: this.origin });
|
|
155
155
|
} catch (error) {
|
|
156
156
|
if (error.response) {
|
|
157
|
-
throw new
|
|
157
|
+
throw new errors_index.CuencaResponseException(
|
|
158
158
|
error.response.data,
|
|
159
159
|
error.response.status,
|
|
160
160
|
);
|
|
161
161
|
} else if (error.request) {
|
|
162
|
-
throw new
|
|
162
|
+
throw new errors_index.CuencaException(
|
|
163
163
|
`No response received: ${error.errno}: ${error.code}`,
|
|
164
164
|
);
|
|
165
165
|
} else {
|
|
166
|
-
throw new
|
|
166
|
+
throw new errors_index.CuencaException(error.message);
|
|
167
167
|
}
|
|
168
168
|
} finally {
|
|
169
169
|
headersInterceptor.eject();
|
|
@@ -931,8 +931,8 @@ const Queryable = (SuperClass) =>
|
|
|
931
931
|
params: queryParams.toParams(),
|
|
932
932
|
});
|
|
933
933
|
|
|
934
|
-
if (!items || !items.length) throw new
|
|
935
|
-
if (items.length > 1) throw new
|
|
934
|
+
if (!items || !items.length) throw new errors_index.NoResultFound();
|
|
935
|
+
if (items.length > 1) throw new errors_index.MultipleResultsFound();
|
|
936
936
|
|
|
937
937
|
const [item] = items;
|
|
938
938
|
const model = getModelFromPath(this.path, item);
|
|
@@ -1383,7 +1383,7 @@ class UserLoginResource extends mix(Resource).with(Creatable, Deactivable) {
|
|
|
1383
1383
|
async create(password, userId) {
|
|
1384
1384
|
const request = new walletTransactionRequest.UserLoginRequest(password, userId);
|
|
1385
1385
|
const userLogin = await this._create(request.toObject());
|
|
1386
|
-
if (!userLogin.success) throw new
|
|
1386
|
+
if (!userLogin.success) throw new errors_index.InvalidPassword();
|
|
1387
1387
|
|
|
1388
1388
|
// Set login id to headers
|
|
1389
1389
|
this.loginIdInHeaders = this.client.addHeadersToRequest({
|
|
@@ -1477,14 +1477,14 @@ class Cuenca {
|
|
|
1477
1477
|
}
|
|
1478
1478
|
}
|
|
1479
1479
|
|
|
1480
|
-
exports.CuencaException =
|
|
1481
|
-
exports.CuencaResponseException =
|
|
1482
|
-
exports.InvalidPassword =
|
|
1483
|
-
exports.MalformedJwtToken =
|
|
1484
|
-
exports.MultipleResultsFound =
|
|
1485
|
-
exports.NoResultFound =
|
|
1486
|
-
exports.ValidationError =
|
|
1487
|
-
exports.Jwt =
|
|
1480
|
+
exports.CuencaException = errors_index.CuencaException;
|
|
1481
|
+
exports.CuencaResponseException = errors_index.CuencaResponseException;
|
|
1482
|
+
exports.InvalidPassword = errors_index.InvalidPassword;
|
|
1483
|
+
exports.MalformedJwtToken = errors_index.MalformedJwtToken;
|
|
1484
|
+
exports.MultipleResultsFound = errors_index.MultipleResultsFound;
|
|
1485
|
+
exports.NoResultFound = errors_index.NoResultFound;
|
|
1486
|
+
exports.ValidationError = errors_index.ValidationError;
|
|
1487
|
+
exports.Jwt = jwt_index.Jwt;
|
|
1488
1488
|
exports.AccountQuery = queries.AccountQuery;
|
|
1489
1489
|
exports.ApiKeyQuery = queries.ApiKeyQuery;
|
|
1490
1490
|
exports.BalanceEntryQuery = queries.BalanceEntryQuery;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
-
import { CuencaResponseException, CuencaException, NoResultFound, MultipleResultsFound, InvalidPassword } from './errors.
|
|
3
|
-
export { CuencaException, CuencaResponseException, InvalidPassword, MalformedJwtToken, MultipleResultsFound, NoResultFound, ValidationError } from './errors.
|
|
4
|
-
import { Jwt } from './jwt.
|
|
5
|
-
export { Jwt } from './jwt.
|
|
6
|
-
import { P as Phase, F as FileFormat, E as EntryType, T as TransactionStatus, C as CardIssuer, a as CardStatus, b as CardType, c as CardFundingType, d as CardErrorType, e as CardTransactionType, f as CommissionType, D as DepositNetwork, S as SavingCategory, g as ServiceProviderCategory, h as TransferNetwork, W as WalletTransactionType, A as AccountQuery, i as ApiKeyQuery, B as BalanceEntryQuery, j as BillPaymentQuery, k as CardsQuery, l as CardTransactionQuery, Q as QueryParams, m as DepositQuery, n as WalletQuery, o as StatementQuery, p as TransferQuery, q as WalletTransactionQuery } from './queries-
|
|
7
|
-
export { A as AccountQuery, i as ApiKeyQuery, B as BalanceEntryQuery, j as BillPaymentQuery, d as CardErrorType, c as CardFundingType, C as CardIssuer, a as CardStatus, l as CardTransactionQuery, e as CardTransactionType, b as CardType, k as CardsQuery, f as CommissionType, D as DepositNetwork, m as DepositQuery, E as EntryType, F as FileFormat, s as PageSize, P as Phase, Q as QueryParams, S as SavingCategory, g as ServiceProviderCategory, o as StatementQuery, r as TrackDataMethod, T as TransactionStatus, h as TransferNetwork, p as TransferQuery, n as WalletQuery, q as WalletTransactionQuery, W as WalletTransactionType } from './queries-
|
|
2
|
+
import { CuencaResponseException, CuencaException, NoResultFound, MultipleResultsFound, InvalidPassword } from './errors/index.mjs';
|
|
3
|
+
export { CuencaException, CuencaResponseException, InvalidPassword, MalformedJwtToken, MultipleResultsFound, NoResultFound, ValidationError } from './errors/index.mjs';
|
|
4
|
+
import { Jwt } from './jwt/index.mjs';
|
|
5
|
+
export { Jwt } from './jwt/index.mjs';
|
|
6
|
+
import { P as Phase, F as FileFormat, E as EntryType, T as TransactionStatus, C as CardIssuer, a as CardStatus, b as CardType, c as CardFundingType, d as CardErrorType, e as CardTransactionType, f as CommissionType, D as DepositNetwork, S as SavingCategory, g as ServiceProviderCategory, h as TransferNetwork, W as WalletTransactionType, A as AccountQuery, i as ApiKeyQuery, B as BalanceEntryQuery, j as BillPaymentQuery, k as CardsQuery, l as CardTransactionQuery, Q as QueryParams, m as DepositQuery, n as WalletQuery, o as StatementQuery, p as TransferQuery, q as WalletTransactionQuery } from './queries-f146b91b.js';
|
|
7
|
+
export { A as AccountQuery, i as ApiKeyQuery, B as BalanceEntryQuery, j as BillPaymentQuery, d as CardErrorType, c as CardFundingType, C as CardIssuer, a as CardStatus, l as CardTransactionQuery, e as CardTransactionType, b as CardType, k as CardsQuery, f as CommissionType, D as DepositNetwork, m as DepositQuery, E as EntryType, F as FileFormat, s as PageSize, P as Phase, Q as QueryParams, S as SavingCategory, g as ServiceProviderCategory, o as StatementQuery, r as TrackDataMethod, T as TransactionStatus, h as TransferNetwork, p as TransferQuery, n as WalletQuery, q as WalletTransactionQuery, W as WalletTransactionType } from './queries-f146b91b.js';
|
|
8
8
|
import { d as dateToUTC, e as enumValueFromString } from './data-7d3d5fcc.js';
|
|
9
|
-
import { 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-
|
|
9
|
+
import { 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-bbfb87bd.js';
|
|
10
10
|
|
|
11
11
|
class Client {
|
|
12
12
|
constructor({ apiKey, apiSecret, phase = Phase.Sandbox } = {}) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var errors_index = require('../errors/index.js');
|
|
6
6
|
|
|
7
7
|
class Jwt {
|
|
8
8
|
constructor(expiresAt, token) {
|
|
@@ -23,7 +23,7 @@ class Jwt {
|
|
|
23
23
|
Buffer.from(`${payloadEncoded}==`, 'base64').toString(),
|
|
24
24
|
);
|
|
25
25
|
} catch (error) {
|
|
26
|
-
throw new
|
|
26
|
+
throw new errors_index.MalformedJwtToken();
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
const { exp } = payload;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cuenca-mx/cuenca-js",
|
|
3
|
+
"version": "0.0.1-dev.6",
|
|
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
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var errors_index = require('./errors/index.js');
|
|
4
4
|
var data = require('./data-c53f1052.js');
|
|
5
5
|
|
|
6
6
|
class CardErrorType {
|
|
@@ -530,7 +530,7 @@ class StatementQuery extends QueryParams {
|
|
|
530
530
|
now.setUTCDate(1);
|
|
531
531
|
const date = data.dateToUTC(`${year}-${month}-01`);
|
|
532
532
|
if (date.getTime() >= now.getTime()) {
|
|
533
|
-
throw new
|
|
533
|
+
throw new errors_index.ValidationError(
|
|
534
534
|
`${year}-${month} is not a valid year-month pair`,
|
|
535
535
|
);
|
|
536
536
|
}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var walletTransactionRequest = require('
|
|
6
|
-
require('
|
|
7
|
-
require('
|
|
5
|
+
var walletTransactionRequest = require('../walletTransactionRequest-b588cc52.js');
|
|
6
|
+
require('../errors/index.js');
|
|
7
|
+
require('../data-c53f1052.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -1,3 +1,3 @@
|
|
|
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 '
|
|
2
|
-
import '
|
|
3
|
-
import '
|
|
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-bbfb87bd.js';
|
|
2
|
+
import '../errors/index.mjs';
|
|
3
|
+
import '../data-7d3d5fcc.js';
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var queries = require('
|
|
6
|
-
require('
|
|
7
|
-
require('
|
|
5
|
+
var queries = require('../queries-b8f29837.js');
|
|
6
|
+
require('../errors/index.js');
|
|
7
|
+
require('../data-c53f1052.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as AccountQuery, i as ApiKeyQuery, B as BalanceEntryQuery, j as BillPaymentQuery, d as CardErrorType, c as CardFundingType, C as CardIssuer, a as CardStatus, l as CardTransactionQuery, e as CardTransactionType, b as CardType, k as CardsQuery, f as CommissionType, D as DepositNetwork, m as DepositQuery, E as EntryType, F as FileFormat, s as PageSize, P as Phase, Q as QueryParams, S as SavingCategory, g as ServiceProviderCategory, o as StatementQuery, r as TrackDataMethod, T as TransactionStatus, h as TransferNetwork, p as TransferQuery, n as WalletQuery, q as WalletTransactionQuery, W as WalletTransactionType } from '
|
|
2
|
-
import '
|
|
3
|
-
import '
|
|
1
|
+
export { A as AccountQuery, i as ApiKeyQuery, B as BalanceEntryQuery, j as BillPaymentQuery, d as CardErrorType, c as CardFundingType, C as CardIssuer, a as CardStatus, l as CardTransactionQuery, e as CardTransactionType, b as CardType, k as CardsQuery, f as CommissionType, D as DepositNetwork, m as DepositQuery, E as EntryType, F as FileFormat, s as PageSize, P as Phase, Q as QueryParams, S as SavingCategory, g as ServiceProviderCategory, o as StatementQuery, r as TrackDataMethod, T as TransactionStatus, h as TransferNetwork, p as TransferQuery, n as WalletQuery, q as WalletTransactionQuery, W as WalletTransactionType } from '../queries-f146b91b.js';
|
|
2
|
+
import '../errors/index.mjs';
|
|
3
|
+
import '../data-7d3d5fcc.js';
|
package/build/{cjs/walletTransactionRequest-82837ee6.js → walletTransactionRequest-b588cc52.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var errors_index = require('./errors/index.js');
|
|
4
4
|
var data = require('./data-c53f1052.js');
|
|
5
5
|
|
|
6
6
|
class BaseRequest {
|
|
@@ -64,7 +64,7 @@ class ArpcRequest extends BaseRequest {
|
|
|
64
64
|
if (!value) return;
|
|
65
65
|
const validations = [!!value, value.length === 16, /^\d{16}/.test(value)];
|
|
66
66
|
if (validations.some((x) => !x)) {
|
|
67
|
-
throw new
|
|
67
|
+
throw new errors_index.ValidationError('Invalid number');
|
|
68
68
|
}
|
|
69
69
|
this._number = value;
|
|
70
70
|
}
|
|
@@ -77,7 +77,7 @@ class ArpcRequest extends BaseRequest {
|
|
|
77
77
|
if (!value) return;
|
|
78
78
|
const validations = [value.length === 1];
|
|
79
79
|
if (validations.some((x) => !x)) {
|
|
80
|
-
throw new
|
|
80
|
+
throw new errors_index.ValidationError('Invalid method');
|
|
81
81
|
}
|
|
82
82
|
this._arpcMethod = value;
|
|
83
83
|
}
|
|
@@ -145,7 +145,7 @@ class CardActivationRequest extends BaseRequest {
|
|
|
145
145
|
set n(value) {
|
|
146
146
|
const validations = [!!value, value.length === 16, /^\d{16}/.test(value)];
|
|
147
147
|
if (validations.some((x) => !x)) {
|
|
148
|
-
throw new
|
|
148
|
+
throw new errors_index.ValidationError('Invalid number');
|
|
149
149
|
}
|
|
150
150
|
this._number = value.trim();
|
|
151
151
|
}
|
|
@@ -157,7 +157,7 @@ class CardActivationRequest extends BaseRequest {
|
|
|
157
157
|
set eM(value) {
|
|
158
158
|
const validations = [!!value, value >= 1, value <= 12];
|
|
159
159
|
if (validations.some((x) => !x)) {
|
|
160
|
-
throw new
|
|
160
|
+
throw new errors_index.ValidationError('Invalid expiration month');
|
|
161
161
|
}
|
|
162
162
|
this._expMonth = value;
|
|
163
163
|
}
|
|
@@ -169,7 +169,7 @@ class CardActivationRequest extends BaseRequest {
|
|
|
169
169
|
set eY(value) {
|
|
170
170
|
const validations = [!!value, value >= 18, value <= 99];
|
|
171
171
|
if (validations.some((x) => !x)) {
|
|
172
|
-
throw new
|
|
172
|
+
throw new errors_index.ValidationError('Invalid expiration year');
|
|
173
173
|
}
|
|
174
174
|
this._expYear = value;
|
|
175
175
|
}
|
|
@@ -181,7 +181,7 @@ class CardActivationRequest extends BaseRequest {
|
|
|
181
181
|
set c2(value) {
|
|
182
182
|
const validations = [!!value, value.length === 3, /^\d{3}/.test(value)];
|
|
183
183
|
if (validations.some((x) => !x)) {
|
|
184
|
-
throw new
|
|
184
|
+
throw new errors_index.ValidationError('Invalid cvv2');
|
|
185
185
|
}
|
|
186
186
|
this._cvv2 = value;
|
|
187
187
|
}
|
|
@@ -226,7 +226,7 @@ class CardValidationRequest extends BaseRequest {
|
|
|
226
226
|
if (!value) return;
|
|
227
227
|
const validations = [value.length === 3];
|
|
228
228
|
if (validations.some((x) => !x)) {
|
|
229
|
-
throw new
|
|
229
|
+
throw new errors_index.ValidationError('Invalid cvv');
|
|
230
230
|
}
|
|
231
231
|
this._cvv = value;
|
|
232
232
|
}
|
|
@@ -239,7 +239,7 @@ class CardValidationRequest extends BaseRequest {
|
|
|
239
239
|
if (!value) return;
|
|
240
240
|
const validations = [value.length === 3];
|
|
241
241
|
if (validations.some((x) => !x)) {
|
|
242
|
-
throw new
|
|
242
|
+
throw new errors_index.ValidationError('Invalid cvv2');
|
|
243
243
|
}
|
|
244
244
|
this._cvv2 = value;
|
|
245
245
|
}
|
|
@@ -252,7 +252,7 @@ class CardValidationRequest extends BaseRequest {
|
|
|
252
252
|
if (!value) return;
|
|
253
253
|
const validations = [value >= 1, value <= 12];
|
|
254
254
|
if (validations.some((x) => !x)) {
|
|
255
|
-
throw new
|
|
255
|
+
throw new errors_index.ValidationError('Invalid expiration month');
|
|
256
256
|
}
|
|
257
257
|
this._expMonth = value;
|
|
258
258
|
}
|
|
@@ -265,7 +265,7 @@ class CardValidationRequest extends BaseRequest {
|
|
|
265
265
|
if (!value) return;
|
|
266
266
|
const validations = [value >= 18, value <= 99];
|
|
267
267
|
if (validations.some((x) => !x)) {
|
|
268
|
-
throw new
|
|
268
|
+
throw new errors_index.ValidationError('Invalid expiration year');
|
|
269
269
|
}
|
|
270
270
|
this._expYear = value;
|
|
271
271
|
}
|
|
@@ -278,7 +278,7 @@ class CardValidationRequest extends BaseRequest {
|
|
|
278
278
|
if (!value) return;
|
|
279
279
|
const validations = [value.length === 3];
|
|
280
280
|
if (validations.some((x) => !x)) {
|
|
281
|
-
throw new
|
|
281
|
+
throw new errors_index.ValidationError('Invalid icvv');
|
|
282
282
|
}
|
|
283
283
|
this._icvv = value;
|
|
284
284
|
}
|
|
@@ -290,7 +290,7 @@ class CardValidationRequest extends BaseRequest {
|
|
|
290
290
|
set n(value) {
|
|
291
291
|
const validations = [!!value, value.length === 16, /^\d{16}/.test(value)];
|
|
292
292
|
if (validations.some((x) => !x)) {
|
|
293
|
-
throw new
|
|
293
|
+
throw new errors_index.ValidationError('Invalid number');
|
|
294
294
|
}
|
|
295
295
|
this._number = value;
|
|
296
296
|
}
|
|
@@ -325,7 +325,7 @@ class SavingRequest extends BaseRequest {
|
|
|
325
325
|
set validDate(value) {
|
|
326
326
|
if (!value) return;
|
|
327
327
|
if (data.dateToUTC(value).getTime() <= data.dateToUTC(Date.now()).getTime()) {
|
|
328
|
-
throw new
|
|
328
|
+
throw new errors_index.ValidationError(
|
|
329
329
|
'The goal_date always need to be higher than now',
|
|
330
330
|
);
|
|
331
331
|
}
|
|
@@ -382,7 +382,7 @@ class UserCredentialRequest extends BaseRequest {
|
|
|
382
382
|
set pwd(value) {
|
|
383
383
|
const validations = [!!value, value.length === 6, /^\d{6}$/.test(value)];
|
|
384
384
|
if (validations.some((x) => !x)) {
|
|
385
|
-
throw new
|
|
385
|
+
throw new errors_index.ValidationError('Invalid password');
|
|
386
386
|
}
|
|
387
387
|
this._password = value;
|
|
388
388
|
}
|
|
@@ -420,14 +420,14 @@ class UserCredentialUpdateRequest extends BaseRequest {
|
|
|
420
420
|
}
|
|
421
421
|
const validations = [value.length === 6, /^\d{6}$/.test(value)];
|
|
422
422
|
if (validations.some((x) => !x)) {
|
|
423
|
-
throw new
|
|
423
|
+
throw new errors_index.ValidationError('Invalid password');
|
|
424
424
|
}
|
|
425
425
|
this._password = value;
|
|
426
426
|
}
|
|
427
427
|
|
|
428
428
|
set req(value) {
|
|
429
429
|
if (value.password && value.isActive != null) {
|
|
430
|
-
throw new
|
|
430
|
+
throw new errors_index.ValidationError('Only one property can be updated at a time');
|
|
431
431
|
}
|
|
432
432
|
this._request = value;
|
|
433
433
|
}
|
|
@@ -454,7 +454,7 @@ class UserLoginRequest extends BaseRequest {
|
|
|
454
454
|
set pwd(value) {
|
|
455
455
|
const validations = [!!value, value.length === 6, /^\d{6}$/.test(value)];
|
|
456
456
|
if (validations.some((x) => !x)) {
|
|
457
|
-
throw new
|
|
457
|
+
throw new errors_index.ValidationError('Invalid password');
|
|
458
458
|
}
|
|
459
459
|
this._password = value;
|
|
460
460
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuenca-mx/cuenca-js",
|
|
3
|
-
"version": "0.0.1-dev.
|
|
3
|
+
"version": "0.0.1-dev.6",
|
|
4
4
|
"description": "Cuenca client for JS",
|
|
5
|
-
"main": "./build/
|
|
6
|
-
"module": "./build/
|
|
5
|
+
"main": "./build/index.js",
|
|
6
|
+
"module": "./build/index.mjs",
|
|
7
7
|
"browser": "./build/umd/cuenca.umd.js",
|
|
8
8
|
"files": [
|
|
9
9
|
"build/**/*"
|
|
10
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
|
+
},
|
|
11
18
|
"packageManager": "yarn@3.0.2",
|
|
12
19
|
"type": "module",
|
|
13
20
|
"repository": {
|
|
@@ -24,13 +31,15 @@
|
|
|
24
31
|
},
|
|
25
32
|
"homepage": "https://cuenca.com",
|
|
26
33
|
"scripts": {
|
|
27
|
-
"build": "rm -rf build/ && yarn rollup
|
|
34
|
+
"build": "rm -rf build/ && yarn node ./scripts/rollup/rollup.cjs",
|
|
28
35
|
"test": "yarn node --experimental-vm-modules $(yarn bin jest)",
|
|
29
36
|
"publish": "yarn build && yarn npm publish"
|
|
30
37
|
},
|
|
31
38
|
"devDependencies": {
|
|
32
39
|
"@rollup/plugin-commonjs": "^21.0.1",
|
|
33
40
|
"@rollup/plugin-node-resolve": "^13.1.1",
|
|
41
|
+
"chalk": "^4.1.2",
|
|
42
|
+
"fs-extra": "^10.0.0",
|
|
34
43
|
"jest": "^27.4.5",
|
|
35
44
|
"rollup": "^2.61.1",
|
|
36
45
|
"rollup-plugin-terser": "^7.0.2"
|