@vtex/api 6.45.7 → 6.45.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/CHANGELOG.md +6 -0
- package/lib/service/worker/runtime/graphql/utils/error.js +4 -5
- package/lib/service/worker/runtime/http/middlewares/error.js +1 -2
- package/lib/utils/error.d.ts +1 -0
- package/lib/utils/error.js +1 -0
- package/lib/utils/json.d.ts +5 -0
- package/lib/utils/json.js +18 -0
- package/lib/utils/log.d.ts +3 -3
- package/lib/utils/log.js +3 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ramda_1 = require("ramda");
|
|
4
4
|
const error_1 = require("../../../../../utils/error");
|
|
5
|
-
const log_1 = require("../../../../../utils/log");
|
|
6
5
|
const ERROR_FIELD_WHITELIST = ['message', 'path', 'stack', 'extensions', 'statusCode', 'name', 'headers', 'originalError', 'code'];
|
|
7
6
|
const QUERY_FIELDS = ['query', 'operationName', 'variables'];
|
|
8
7
|
const trimVariables = (variables) => {
|
|
@@ -49,8 +48,8 @@ const formatError = (error, details) => {
|
|
|
49
48
|
formattedError.extensions.exception = {
|
|
50
49
|
message: formattedError.originalError.message,
|
|
51
50
|
name: formattedError.originalError.name,
|
|
52
|
-
...ramda_1.omit(
|
|
53
|
-
sensitive: ramda_1.pick(
|
|
51
|
+
...ramda_1.omit(error_1.SENSITIVE_EXCEPTION_FIELDS, formattedError.originalError),
|
|
52
|
+
sensitive: ramda_1.pick(error_1.SENSITIVE_EXCEPTION_FIELDS, formattedError.originalError),
|
|
54
53
|
};
|
|
55
54
|
}
|
|
56
55
|
else {
|
|
@@ -60,8 +59,8 @@ const formatError = (error, details) => {
|
|
|
60
59
|
const extendedException = {
|
|
61
60
|
message: formattedError.originalError.message,
|
|
62
61
|
name: formattedError.originalError.name,
|
|
63
|
-
...ramda_1.omit(
|
|
64
|
-
sensitive: ramda_1.pick(
|
|
62
|
+
...ramda_1.omit(error_1.SENSITIVE_EXCEPTION_FIELDS, mergedException),
|
|
63
|
+
sensitive: ramda_1.pick(error_1.SENSITIVE_EXCEPTION_FIELDS, mergedException),
|
|
65
64
|
};
|
|
66
65
|
formattedError.extensions.exception = error_1.cleanError(extendedException);
|
|
67
66
|
}
|
|
@@ -4,7 +4,6 @@ const constants_1 = require("../../../../../constants");
|
|
|
4
4
|
const RequestCancelledError_1 = require("../../../../../errors/RequestCancelledError");
|
|
5
5
|
const TooManyRequestsError_1 = require("../../../../../errors/TooManyRequestsError");
|
|
6
6
|
const error_1 = require("../../../../../utils/error");
|
|
7
|
-
const log_1 = require("../../../../../utils/log");
|
|
8
7
|
const logger_1 = require("../../../../logger");
|
|
9
8
|
const CACHE_CONTROL_HEADER = 'cache-control';
|
|
10
9
|
const META_HEADER = 'x-vtex-meta';
|
|
@@ -40,7 +39,7 @@ const logAndRemoveSensitiveData = (ctx, err) => {
|
|
|
40
39
|
// Use sendLog directly to avoid cleaning error twice.
|
|
41
40
|
ctx.vtex.logger.log(log, level);
|
|
42
41
|
if (!constants_1.LINKED) {
|
|
43
|
-
|
|
42
|
+
error_1.SENSITIVE_EXCEPTION_FIELDS.forEach(field => {
|
|
44
43
|
delete err[field];
|
|
45
44
|
});
|
|
46
45
|
}
|
package/lib/utils/error.d.ts
CHANGED
package/lib/utils/error.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
// Inspired by https://github.com/sindresorhus/serialize-error
|
|
4
4
|
const ramda_1 = require("ramda");
|
|
5
5
|
exports.PICKED_AXIOS_PROPS = ['baseURL', 'cacheable', 'data', 'finished', 'headers', 'method', 'timeout', 'status', 'path', 'url', 'metric', 'inflightKey', 'forceMaxAge', 'params', 'responseType'];
|
|
6
|
+
exports.SENSITIVE_EXCEPTION_FIELDS = ['config', 'request', 'stack'];
|
|
6
7
|
const MAX_ERROR_STRING_LENGTH = process.env.MAX_ERROR_STRING_LENGTH ? parseInt(process.env.MAX_ERROR_STRING_LENGTH, 10) : 8 * 1024;
|
|
7
8
|
const findCaseInsensitive = (target, set) => ramda_1.find(t => t.toLocaleLowerCase() === target, set);
|
|
8
9
|
const destroyCircular = (from, seen) => {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function cleanJson(json, targetFields) {
|
|
4
|
+
for (const key of json.keys()) {
|
|
5
|
+
let deleted = false;
|
|
6
|
+
for (const field of targetFields) {
|
|
7
|
+
if (key === field) {
|
|
8
|
+
delete json[key];
|
|
9
|
+
deleted = true;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
if (!deleted && typeof json[key] === 'object') {
|
|
13
|
+
json[key] = cleanJson(json[key], targetFields);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return json;
|
|
17
|
+
}
|
|
18
|
+
exports.cleanJson = cleanJson;
|
package/lib/utils/log.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export declare const cleanLog: (log: any) => {
|
|
2
|
+
[k: string]: any;
|
|
3
|
+
};
|
package/lib/utils/log.js
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const json_1 = require("./json");
|
|
4
|
+
const SENSITIVE_FIELDS = ['cookie', 'Cookie', 'vtexIdclientautcookie', 'error'];
|
|
5
5
|
exports.cleanLog = (log) => {
|
|
6
|
-
|
|
7
|
-
delete log[field];
|
|
8
|
-
});
|
|
9
|
-
exports.SECOND_LEVEL_SENSITIVE_FIELDS.forEach(field => {
|
|
10
|
-
if (field[0] in log) {
|
|
11
|
-
delete log[field[0]][field[1]];
|
|
12
|
-
}
|
|
13
|
-
});
|
|
6
|
+
return json_1.cleanJson(log, SENSITIVE_FIELDS);
|
|
14
7
|
};
|