@vtex/api 6.45.6 → 6.45.9
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 +18 -0
- package/lib/service/logger/logger.js +2 -0
- package/lib/utils/json.d.ts +5 -0
- package/lib/utils/json.js +18 -0
- package/lib/utils/log.d.ts +3 -0
- package/lib/utils/log.js +7 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [6.45.9] - 2022-03-08
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Fix cleanJson utility.
|
|
15
|
+
|
|
16
|
+
## [6.45.8] - 2022-02-25
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- Remove only cookie fields when cleaning logs.
|
|
21
|
+
|
|
22
|
+
## [6.45.7] - 2022-02-23
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- Remove sensitive data from logs.
|
|
27
|
+
|
|
10
28
|
## [6.45.6] - 2021-10-26
|
|
11
29
|
|
|
12
30
|
### Fixed
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const constants_1 = require("../../constants");
|
|
4
4
|
const error_1 = require("../../utils/error");
|
|
5
|
+
const log_1 = require("../../utils/log");
|
|
5
6
|
const console_1 = require("./console");
|
|
6
7
|
const linked = !!process.env.VTEX_APP_LINK;
|
|
7
8
|
const app = constants_1.APP.ID;
|
|
@@ -22,6 +23,7 @@ class Logger {
|
|
|
22
23
|
this.log = (message, level) => {
|
|
23
24
|
var _a;
|
|
24
25
|
const data = message ? error_1.cleanError(message) : EMPTY_MESSAGE;
|
|
26
|
+
log_1.cleanLog(data);
|
|
25
27
|
/* tslint:disable:object-literal-sort-keys */
|
|
26
28
|
const inflatedLog = {
|
|
27
29
|
__VTEX_IO_LOG: true,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function cleanJson(json, targetFields) {
|
|
4
|
+
for (const key of Object.keys(json)) {
|
|
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 && json[key] && 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.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const json_1 = require("./json");
|
|
4
|
+
const SENSITIVE_FIELDS = ['cookie', 'Cookie', 'vtexIdclientautcookie', 'error'];
|
|
5
|
+
exports.cleanLog = (log) => {
|
|
6
|
+
return json_1.cleanJson(log, SENSITIVE_FIELDS);
|
|
7
|
+
};
|