@cuenca-mx/cuenca-js 0.0.1-dev.4 → 0.0.1-dev.8
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/errors/index.mjs +64 -0
- package/build/index.mjs +1475 -0
- package/build/jwt/index.mjs +46 -0
- package/build/{queries-395c7467.js → queries-f146b91b.js} +1 -1
- package/build/requests/index.mjs +3 -0
- package/build/types/index.mjs +3 -0
- package/build/{walletTransactionRequest-17132eb5.js → walletTransactionRequest-bbfb87bd.js} +1 -1
- package/package.json +22 -9
- package/build/README.md +0 -7
- package/build/package.json +0 -37
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { MalformedJwtToken } from '../errors/index.mjs';
|
|
2
|
+
|
|
3
|
+
class Jwt {
|
|
4
|
+
constructor(expiresAt, token) {
|
|
5
|
+
this.expiresAt = expiresAt;
|
|
6
|
+
this.token = token;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
get isExpired() {
|
|
10
|
+
const today = new Date();
|
|
11
|
+
return (this.expiresAt.valueOf() - today.valueOf()) / 60000 <= 5;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static getExpirationDate = (token) => {
|
|
15
|
+
let payload;
|
|
16
|
+
try {
|
|
17
|
+
const [, payloadEncoded] = token.split('.');
|
|
18
|
+
payload = JSON.parse(
|
|
19
|
+
Buffer.from(`${payloadEncoded}==`, 'base64').toString(),
|
|
20
|
+
);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
throw new MalformedJwtToken();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const { exp } = payload;
|
|
26
|
+
return new Date(new Date(exp * 1000).toUTCString());
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
static create = async (client) => {
|
|
30
|
+
const currentClient = client;
|
|
31
|
+
currentClient.jwtToken = null;
|
|
32
|
+
// Intercepts requests and removes the header if it includes it
|
|
33
|
+
const tokenInterceptor =
|
|
34
|
+
currentClient.deleteRequestHeader('X-Cuenca-Token');
|
|
35
|
+
|
|
36
|
+
const { token } = await client.post('token', {});
|
|
37
|
+
|
|
38
|
+
// Remove the interceptor to avoid removing the header on all requests
|
|
39
|
+
tokenInterceptor.eject();
|
|
40
|
+
|
|
41
|
+
const expiresAt = Jwt.getExpirationDate(token);
|
|
42
|
+
return new Jwt(expiresAt, token);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { Jwt };
|
|
@@ -0,0 +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 '../walletTransactionRequest-bbfb87bd.js';
|
|
2
|
+
import '../errors/index.mjs';
|
|
3
|
+
import '../data-7d3d5fcc.js';
|
|
@@ -0,0 +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 '../queries-f146b91b.js';
|
|
2
|
+
import '../errors/index.mjs';
|
|
3
|
+
import '../data-7d3d5fcc.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuenca-mx/cuenca-js",
|
|
3
|
-
"version": "0.0.1-dev.
|
|
3
|
+
"version": "0.0.1-dev.8",
|
|
4
4
|
"description": "Cuenca client for JS",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"module": "./build/index.mjs",
|
|
@@ -9,11 +9,26 @@
|
|
|
9
9
|
"build/**/*"
|
|
10
10
|
],
|
|
11
11
|
"exports": {
|
|
12
|
-
".":
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"./
|
|
12
|
+
".": [
|
|
13
|
+
"./build/index.mjs",
|
|
14
|
+
"./build/index.js"
|
|
15
|
+
],
|
|
16
|
+
"./errors": [
|
|
17
|
+
"./build/errors/index.mjs",
|
|
18
|
+
"./build/errors/index.js"
|
|
19
|
+
],
|
|
20
|
+
"./jwt": [
|
|
21
|
+
"./build/jwt/index.mjs",
|
|
22
|
+
"./build/jwt/index.js"
|
|
23
|
+
],
|
|
24
|
+
"./requests": [
|
|
25
|
+
"./build/requests/index.mjs",
|
|
26
|
+
"./build/requests/index.js"
|
|
27
|
+
],
|
|
28
|
+
"./types": [
|
|
29
|
+
"./build/types/index.mjs",
|
|
30
|
+
"./build/types/index.js"
|
|
31
|
+
]
|
|
17
32
|
},
|
|
18
33
|
"packageManager": "yarn@3.0.2",
|
|
19
34
|
"type": "module",
|
|
@@ -31,15 +46,13 @@
|
|
|
31
46
|
},
|
|
32
47
|
"homepage": "https://cuenca.com",
|
|
33
48
|
"scripts": {
|
|
34
|
-
"build": "rm -rf build/ && yarn
|
|
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
54
|
"@rollup/plugin-commonjs": "^21.0.1",
|
|
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"
|
package/build/README.md
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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
|
package/build/package.json
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@cuenca-mx/cuenca-js",
|
|
3
|
-
"version": "0.0.1-dev.4",
|
|
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/",
|
|
14
|
-
"./jwt/": "./build/jwt/",
|
|
15
|
-
"./requests/": "./build/requests/",
|
|
16
|
-
"./types/": "./build/types/"
|
|
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
|
-
}
|