@vtex/api 3.77.4 → 3.77.7
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 +17 -0
- package/lib/service/logger/index.js +2 -0
- package/lib/utils/json.d.ts +5 -0
- package/lib/utils/json.js +18 -0
- package/lib/utils/log.d.ts +5 -0
- package/lib/utils/log.js +20 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [3.77.7] - 2022-04-14
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- Update sensitive fields.
|
|
14
|
+
- Remove "error".
|
|
15
|
+
- Add missing fields.
|
|
16
|
+
- Fix cleanJson.
|
|
17
|
+
- Lowercase keys before comparison.
|
|
18
|
+
|
|
19
|
+
## [3.77.6] - 2022-03-08
|
|
20
|
+
### Fixed
|
|
21
|
+
- Only remove cookie fields when removing sensitive data from logs.
|
|
22
|
+
|
|
23
|
+
## [3.77.5] - 2022-02-24
|
|
24
|
+
### Fixed
|
|
25
|
+
- Remove sensitive data from logs.
|
|
26
|
+
|
|
10
27
|
## [3.77.4] - 2021-10-22
|
|
11
28
|
|
|
12
29
|
## [3.77.3] - 2021-10-22
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const error_1 = require("../../utils/error");
|
|
4
|
+
const log_1 = require("../../utils/log");
|
|
4
5
|
const linked = !!process.env.VTEX_APP_LINK;
|
|
5
6
|
const app = process.env.VTEX_APP_ID;
|
|
6
7
|
const EMPTY_MESSAGE = 'Logger.log was called with null or undefined message';
|
|
@@ -22,6 +23,7 @@ class Logger {
|
|
|
22
23
|
this.error = (error) => this.log(error, LogLevel.Error);
|
|
23
24
|
this.log = (message, level) => {
|
|
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.toLowerCase() === 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,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const json_1 = require("./json");
|
|
4
|
+
const SENSITIVE_FIELDS = [
|
|
5
|
+
'auth',
|
|
6
|
+
'authorization',
|
|
7
|
+
'authtoken',
|
|
8
|
+
'cookie',
|
|
9
|
+
'proxy-athorization',
|
|
10
|
+
'rawheaders',
|
|
11
|
+
'token',
|
|
12
|
+
'vtexIdclientautcookie',
|
|
13
|
+
'x-vtex-api-appkey',
|
|
14
|
+
'x-vtex-api-apptoken',
|
|
15
|
+
'x-vtex-credential',
|
|
16
|
+
'x-vtex-session',
|
|
17
|
+
];
|
|
18
|
+
exports.cleanLog = (log) => {
|
|
19
|
+
return json_1.cleanJson(log, SENSITIVE_FIELDS);
|
|
20
|
+
};
|