@vtex/api 3.77.6 → 3.77.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 CHANGED
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [3.77.8] - 2022-12-15
11
+ ### Changed
12
+ - Remove socket metrics per origin
13
+
14
+ ## [3.77.7] - 2022-04-14
15
+
16
+ ### Fixed
17
+ - Update sensitive fields.
18
+ - Remove "error".
19
+ - Add missing fields.
20
+ - Fix cleanJson.
21
+ - Lowercase keys before comparison.
22
+
10
23
  ## [3.77.6] - 2022-03-08
11
24
  ### Fixed
12
25
  - Only remove cookie fields when removing sensitive data from logs.
@@ -1004,3 +1017,7 @@ instead
1004
1017
  ## [0.48.0] - 2018-09-21
1005
1018
  ### Changed
1006
1019
  - `HttpClient` now adds `'Accept-Encoding': 'gzip'` header by default.
1020
+
1021
+
1022
+ [Unreleased]: https://github.com/vtex/node-vtex-api/compare/v3.77.8...HEAD
1023
+ [3.77.8]: https://github.com/vtex/node-vtex-api/compare/v3.77.7...v3.77.8
@@ -5,9 +5,6 @@ export declare const routerCacheMiddleware: (ctx: MiddlewareContext, next: () =>
5
5
  export declare const requestMiddleware: (limit?: Limit | undefined) => (ctx: MiddlewareContext, next: () => Promise<void>) => Promise<void>;
6
6
  export declare function httpAgentStats(): {
7
7
  freeSockets: number;
8
- freeSocketsPerOrigin: Record<string, number>;
9
8
  pendingRequests: number;
10
- pendingRequestsPerOrigin: Record<string, number>;
11
9
  sockets: number;
12
- socketsPerOrigin: Record<string, number>;
13
10
  };
@@ -66,28 +66,22 @@ exports.requestMiddleware = (limit) => async (ctx, next) => {
66
66
  const makeRequest = () => http.request(ctx.config);
67
67
  ctx.response = await (limit ? limit(makeRequest) : makeRequest());
68
68
  };
69
- function countPerOrigin(obj) {
69
+ function count(obj) {
70
70
  try {
71
- return ramda_1.mapObjIndexed(val => val.length, obj);
71
+ return Object.values(obj).reduce((acc, val) => acc += val.length, 0);
72
72
  }
73
73
  catch (_) {
74
- return {};
74
+ return 0;
75
75
  }
76
76
  }
77
77
  function httpAgentStats() {
78
- const socketsPerOrigin = countPerOrigin(httpAgent.sockets);
79
- const sockets = ramda_1.sum(ramda_1.values(socketsPerOrigin));
80
- const freeSocketsPerOrigin = countPerOrigin(httpAgent.freeSockets);
81
- const freeSockets = ramda_1.sum(ramda_1.values(freeSocketsPerOrigin));
82
- const pendingRequestsPerOrigin = countPerOrigin(httpAgent.requests);
83
- const pendingRequests = ramda_1.sum(ramda_1.values(pendingRequestsPerOrigin));
78
+ const sockets = count(httpAgent.sockets);
79
+ const freeSockets = count(httpAgent.freeSockets);
80
+ const pendingRequests = count(httpAgent.requests);
84
81
  return {
85
82
  freeSockets,
86
- freeSocketsPerOrigin,
87
83
  pendingRequests,
88
- pendingRequestsPerOrigin,
89
84
  sockets,
90
- socketsPerOrigin,
91
85
  };
92
86
  }
93
87
  exports.httpAgentStats = httpAgentStats;
package/lib/utils/json.js CHANGED
@@ -4,7 +4,7 @@ function cleanJson(json, targetFields) {
4
4
  for (const key of Object.keys(json)) {
5
5
  let deleted = false;
6
6
  for (const field of targetFields) {
7
- if (key === field) {
7
+ if (key.toLowerCase() === field) {
8
8
  delete json[key];
9
9
  deleted = true;
10
10
  }
package/lib/utils/log.js CHANGED
@@ -1,7 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const json_1 = require("./json");
4
- const SENSITIVE_FIELDS = ['cookie', 'Cookie', 'vtexIdclientautcookie', 'error'];
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
+ ];
5
18
  exports.cleanLog = (log) => {
6
19
  return json_1.cleanJson(log, SENSITIVE_FIELDS);
7
20
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/api",
3
- "version": "3.77.6",
3
+ "version": "3.77.8",
4
4
  "description": "VTEX I/O API client",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",