@pxp-nd/core 1.2.74 → 1.2.77
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/dist/PxpApp.js +4 -5
- package/dist/interfaces.d.ts +4 -1
- package/dist/lib/pxp/PxpError.d.ts +3 -3
- package/dist/lib/pxp/PxpError.js +14 -8
- package/dist/lib/pxp/utils/Security.js +14 -12
- package/package.json +1 -1
package/dist/PxpApp.js
CHANGED
|
@@ -45,7 +45,7 @@ const modulesPxp = {
|
|
|
45
45
|
common: '@pxp-nd/common',
|
|
46
46
|
reports: '@pxp-nd/reports',
|
|
47
47
|
};
|
|
48
|
-
//auth configure
|
|
48
|
+
//auth configure
|
|
49
49
|
/**
|
|
50
50
|
*
|
|
51
51
|
* */
|
|
@@ -125,9 +125,8 @@ class PxpApp {
|
|
|
125
125
|
}
|
|
126
126
|
next();
|
|
127
127
|
});
|
|
128
|
-
this.app.use(express_1.default.json(
|
|
129
|
-
this.app.use(express_1.default.urlencoded({
|
|
130
|
-
console.log('llegggga aca nuevo');
|
|
128
|
+
this.app.use(express_1.default.json());
|
|
129
|
+
this.app.use(express_1.default.urlencoded({ extended: false }));
|
|
131
130
|
this.app.use(express_fileupload_1.default({
|
|
132
131
|
limits: { fileSize: 5 * 1024 * 1024 },
|
|
133
132
|
}));
|
|
@@ -265,7 +264,7 @@ class PxpApp {
|
|
|
265
264
|
if (this.config.auth) {
|
|
266
265
|
await this.initializeAuthentication(this.configAuth);
|
|
267
266
|
}
|
|
268
|
-
// load ioServer
|
|
267
|
+
// load ioServer
|
|
269
268
|
this.loadIOserver();
|
|
270
269
|
// load controllers and routes
|
|
271
270
|
await this.loadControllers();
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -7,6 +7,9 @@ declare interface IAuthLocal {
|
|
|
7
7
|
verifyUser: any;
|
|
8
8
|
fields: IAuthields;
|
|
9
9
|
}
|
|
10
|
+
declare interface IAuthJWT {
|
|
11
|
+
verifyUser: any;
|
|
12
|
+
}
|
|
10
13
|
declare interface ISerialize {
|
|
11
14
|
(userPayload: any, done: any): any;
|
|
12
15
|
}
|
|
@@ -17,7 +20,7 @@ declare interface IAuthPxp {
|
|
|
17
20
|
serialize: ISerialize;
|
|
18
21
|
deserialize: IDeserialize;
|
|
19
22
|
local?: boolean | IAuthLocal;
|
|
20
|
-
jwt?: boolean |
|
|
23
|
+
jwt?: boolean | IAuthJWT;
|
|
21
24
|
}
|
|
22
25
|
declare interface IModule {
|
|
23
26
|
entities?: any;
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
* Created at : 2020-06-13 18:09:48
|
|
12
12
|
* Last modified : 2020-09-20 18:20:43
|
|
13
13
|
*/
|
|
14
|
-
import express from
|
|
14
|
+
import express from "express";
|
|
15
15
|
declare class PxpError extends Error {
|
|
16
16
|
statusCode: number;
|
|
17
17
|
message: string;
|
|
18
18
|
tecMessage: string;
|
|
19
|
-
errorObject:
|
|
20
|
-
constructor(statusCode: number, message: string, errorObject?:
|
|
19
|
+
errorObject: any;
|
|
20
|
+
constructor(statusCode: number, message: string, errorObject?: any, stack?: undefined);
|
|
21
21
|
}
|
|
22
22
|
declare const __: (promise: Promise<any>, myShowError?: boolean) => Promise<any>;
|
|
23
23
|
declare const errorMiddleware: (err: PxpError, req: express.Request, res: any) => any;
|
package/dist/lib/pxp/PxpError.js
CHANGED
|
@@ -14,21 +14,26 @@
|
|
|
14
14
|
*/
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.__ = exports.errorMiddleware = exports.PxpError = void 0;
|
|
17
|
-
const genericMessage =
|
|
17
|
+
const genericMessage = "Web server error. Contact the administrator";
|
|
18
18
|
let showError = false;
|
|
19
19
|
class PxpError extends Error {
|
|
20
|
-
constructor(statusCode, message, errorObject, stack) {
|
|
20
|
+
constructor(statusCode, message, errorObject = undefined, stack) {
|
|
21
21
|
super();
|
|
22
22
|
this.statusCode = statusCode;
|
|
23
23
|
this.message = statusCode === 500 ? genericMessage : message;
|
|
24
24
|
this.errorObject = errorObject;
|
|
25
|
-
|
|
25
|
+
if (errorObject && errorObject.response && errorObject.config) {
|
|
26
|
+
this.tecMessage = `Error in Axios call to ${this.errorObject.config.url}, response: ${JSON.stringify(this.errorObject.response.data)}`;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
this.tecMessage = message;
|
|
30
|
+
}
|
|
26
31
|
this.stack = stack || this.stack;
|
|
27
32
|
}
|
|
28
33
|
}
|
|
29
34
|
exports.PxpError = PxpError;
|
|
30
35
|
// Pxp async promise error handler
|
|
31
|
-
const __ = (promise, myShowError = false) =>
|
|
36
|
+
const __ = (promise, myShowError = false) => promise
|
|
32
37
|
.then((data) => data)
|
|
33
38
|
.catch((error) => {
|
|
34
39
|
showError = myShowError || showError;
|
|
@@ -36,21 +41,22 @@ const __ = (promise, myShowError = false) => (promise
|
|
|
36
41
|
throw error;
|
|
37
42
|
}
|
|
38
43
|
else {
|
|
39
|
-
throw new PxpError(showError ? 406 : 500, error.message,
|
|
44
|
+
throw new PxpError(showError ? 406 : 500, error.message, error, error.stack);
|
|
40
45
|
}
|
|
41
|
-
})
|
|
46
|
+
});
|
|
42
47
|
exports.__ = __;
|
|
43
48
|
// error handler middleware
|
|
44
49
|
const errorMiddleware = (err, req, res) => {
|
|
45
50
|
const { statusCode, message, stack, tecMessage, errorObject } = err;
|
|
46
|
-
const extraObj = process.env.NODE_ENV ===
|
|
51
|
+
const extraObj = process.env.NODE_ENV === "production"
|
|
52
|
+
? {}
|
|
53
|
+
: { extendedMessage: tecMessage, stack, errorObject };
|
|
47
54
|
// @todo if production not show tecMessage and stack
|
|
48
55
|
return res.status(err.statusCode || 500).json({
|
|
49
56
|
error: Object.assign({
|
|
50
57
|
code: statusCode,
|
|
51
58
|
message,
|
|
52
59
|
logId: res.logId ? res.logId : undefined,
|
|
53
|
-
errorObject,
|
|
54
60
|
}, extraObj),
|
|
55
61
|
});
|
|
56
62
|
};
|
|
@@ -36,18 +36,20 @@ const userHasPermission = (Role) => async (userId, transaction) => {
|
|
|
36
36
|
};
|
|
37
37
|
exports.userHasPermission = userHasPermission;
|
|
38
38
|
const insertLog = async (username, macaddres, ip, logType, desc, proc, trans, query, req, resp, err, timeEx, logConfig) => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
39
|
+
if (logConfig) {
|
|
40
|
+
for (const [key, value] of Object.entries(logConfig)) {
|
|
41
|
+
if (key in req) {
|
|
42
|
+
if (!value) {
|
|
43
|
+
delete req[key];
|
|
44
|
+
}
|
|
45
|
+
else if (value === 'cc_mask') {
|
|
46
|
+
const aux = req[key];
|
|
47
|
+
req[key] = '************' + aux.substr(-4);
|
|
48
|
+
}
|
|
49
|
+
else if (value === 'complete_mask') {
|
|
50
|
+
const aux = req[key];
|
|
51
|
+
req[key] = aux.replace(/./g, '*');
|
|
52
|
+
}
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
}
|