@vtex/api 6.45.7 → 6.45.10

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 CHANGED
@@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [6.45.10] - 2022-03-15
11
+
12
+ ### Fixed
13
+
14
+ - Update sensitive fields.
15
+ - Add 'authorization', rawheaders', 'x-vtex-credential' and 'x-vtex-session'.
16
+ - Lowercase fields before comparison in cleanJson.
17
+
18
+ ## [6.45.9] - 2022-03-08
19
+
20
+ ### Fixed
21
+
22
+ - Fix cleanJson utility.
23
+
24
+ ## [6.45.8] - 2022-02-25
25
+
26
+ ### Fixed
27
+
28
+ - Remove only cookie fields when cleaning logs.
29
+
10
30
  ## [6.45.7] - 2022-02-23
11
31
 
12
32
  ### Fixed
@@ -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(log_1.FIRST_LEVEL_SENSITIVE_FIELDS, formattedError.originalError),
53
- sensitive: ramda_1.pick(log_1.FIRST_LEVEL_SENSITIVE_FIELDS, formattedError.originalError),
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(log_1.FIRST_LEVEL_SENSITIVE_FIELDS, mergedException),
64
- sensitive: ramda_1.pick(log_1.FIRST_LEVEL_SENSITIVE_FIELDS, mergedException),
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
- log_1.FIRST_LEVEL_SENSITIVE_FIELDS.forEach(field => {
42
+ error_1.SENSITIVE_EXCEPTION_FIELDS.forEach(field => {
44
43
  delete err[field];
45
44
  });
46
45
  }
@@ -1,4 +1,5 @@
1
1
  export declare const PICKED_AXIOS_PROPS: string[];
2
+ export declare const SENSITIVE_EXCEPTION_FIELDS: string[];
2
3
  /**
3
4
  * Cleans errors by removing circular properties, truncating large strings and picking axios properties
4
5
  *
@@ -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,5 @@
1
+ export declare function cleanJson(json: {
2
+ [k: string]: any;
3
+ }, targetFields: string[]): {
4
+ [k: string]: any;
5
+ };
@@ -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;
@@ -1,3 +1,3 @@
1
- export declare const FIRST_LEVEL_SENSITIVE_FIELDS: string[];
2
- export declare const SECOND_LEVEL_SENSITIVE_FIELDS: string[][];
3
- export declare const cleanLog: (log: any) => void;
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
- exports.FIRST_LEVEL_SENSITIVE_FIELDS = ['config', 'request', 'stack', 'error'];
4
- exports.SECOND_LEVEL_SENSITIVE_FIELDS = [['parsedInfo', 'requestConfig'], ['headers', 'cookie']];
3
+ const json_1 = require("./json");
4
+ const SENSITIVE_FIELDS = ['authorization', 'cookie', 'vtexidclientautcookie', 'rawheaders', 'x-vtex-credential', 'x-vtex-session', 'error'];
5
5
  exports.cleanLog = (log) => {
6
- exports.FIRST_LEVEL_SENSITIVE_FIELDS.forEach(field => {
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/api",
3
- "version": "6.45.7",
3
+ "version": "6.45.10",
4
4
  "description": "VTEX I/O API client",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",