@vtex/api 3.77.3 → 3.77.6
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/clients/Segment.d.ts +1 -1
- package/lib/clients/Segment.js +3 -9
- package/lib/clients/Session.d.ts +1 -0
- package/lib/clients/Session.js +1 -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 +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
|
+
## [3.77.6] - 2022-03-08
|
|
11
|
+
### Fixed
|
|
12
|
+
- Only remove cookie fields when removing sensitive data from logs.
|
|
13
|
+
|
|
14
|
+
## [3.77.5] - 2022-02-24
|
|
15
|
+
### Fixed
|
|
16
|
+
- Remove sensitive data from logs.
|
|
17
|
+
|
|
18
|
+
## [3.77.4] - 2021-10-22
|
|
19
|
+
|
|
20
|
+
## [3.77.3] - 2021-10-22
|
|
21
|
+
### Fixed
|
|
22
|
+
- Extract session cookie in a safe manner
|
|
23
|
+
|
|
24
|
+
## [3.77.2] - 2021-08-26
|
|
25
|
+
### Fixed
|
|
26
|
+
- Extract session cookie in a safe manner
|
|
27
|
+
|
|
10
28
|
## [3.77.1] - 2021-02-05
|
|
11
29
|
- Increase HTTP agents connection pools freeSockets and lifetime
|
|
12
30
|
|
package/lib/clients/Segment.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare class Segment extends JanusClient {
|
|
|
34
34
|
getSegmentByToken: (token: string | null) => Promise<SegmentData>;
|
|
35
35
|
getOrCreateSegment: (query?: Record<string, string> | undefined, token?: string | undefined) => Promise<{
|
|
36
36
|
segmentData: SegmentData;
|
|
37
|
-
segmentToken: string;
|
|
37
|
+
segmentToken: string | undefined;
|
|
38
38
|
}>;
|
|
39
39
|
private rawSegment;
|
|
40
40
|
}
|
package/lib/clients/Segment.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const cookie_1 = __importDefault(require("cookie"));
|
|
7
3
|
const ramda_1 = require("ramda");
|
|
8
4
|
const constants_1 = require("../constants");
|
|
9
5
|
const HttpClient_1 = require("../HttpClient");
|
|
10
|
-
const
|
|
6
|
+
const Session_1 = require("./Session");
|
|
11
7
|
const SEGMENT_MAX_AGE_S = 60 * 60; // 60 minutes - segment is actually immutable
|
|
12
8
|
const ALLOWED_QUERY_PREFIXES = ['utm', 'cultureInfo', 'supportedLocales'];
|
|
13
9
|
const filterAndSortQuery = (query) => {
|
|
@@ -48,12 +44,10 @@ class Segment extends HttpClient_1.JanusClient {
|
|
|
48
44
|
*/
|
|
49
45
|
this.getSegmentByToken = (token) => this.rawSegment(token).then(ramda_1.prop('data'));
|
|
50
46
|
this.getOrCreateSegment = async (query, token) => {
|
|
51
|
-
const { data: segmentData, headers
|
|
52
|
-
const parsedCookie = cookie_1.default.parse(setCookies);
|
|
53
|
-
const segmentToken = ramda_1.prop(SEGMENT_COOKIE, parsedCookie);
|
|
47
|
+
const { data: segmentData, headers, } = await this.rawSegment(token, query);
|
|
54
48
|
return {
|
|
55
49
|
segmentData,
|
|
56
|
-
segmentToken,
|
|
50
|
+
segmentToken: Session_1.extractSessionCookie(headers) || token,
|
|
57
51
|
};
|
|
58
52
|
};
|
|
59
53
|
this.rawSegment = (token, query) => {
|
package/lib/clients/Session.d.ts
CHANGED
package/lib/clients/Session.js
CHANGED
|
@@ -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 === 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
|
+
};
|