egg 3.28.0 → 3.30.0

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/README.md CHANGED
@@ -10,7 +10,7 @@ English | [简体中文](./README.zh-CN.md)
10
10
  [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Feggjs%2Fegg.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Feggjs%2Fegg?ref=badge_shield)
11
11
 
12
12
  [![Continuous Integration](https://github.com/eggjs/egg/actions/workflows/nodejs-3.x.yml/badge.svg)](https://github.com/eggjs/egg/actions?query=branch%3A3.x)
13
- [![Test coverage](https://img.shields.io/codecov/c/github/eggjs/egg.svg?style=flat-square)](https://codecov.io/gh/eggjs/egg)
13
+ [![codecov](https://codecov.io/gh/eggjs/egg/branch/3.x/graph/badge.svg?token=2sKMCDNkcl)](https://app.codecov.io/gh/eggjs/egg/tree/3.x)
14
14
  [![Known Vulnerabilities](https://snyk.io/test/npm/egg/badge.svg?style=flat-square)](https://snyk.io/test/npm/egg)
15
15
  [![Open Collective backers and sponsors](https://img.shields.io/opencollective/all/eggjs?style=flat-square)](https://opencollective.com/eggjs)
16
16
 
package/README.zh-CN.md CHANGED
@@ -9,7 +9,7 @@
9
9
  [![NPM download](https://img.shields.io/npm/dm/egg.svg?style=flat-square)](https://npmjs.org/package/egg)
10
10
 
11
11
  [![Continuous Integration](https://github.com/eggjs/egg/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/egg/actions?query=branch%3Amaster)
12
- [![Test coverage](https://img.shields.io/codecov/c/github/eggjs/egg.svg?style=flat-square)](https://codecov.io/gh/eggjs/egg)
12
+ [![codecov](https://codecov.io/gh/eggjs/egg/branch/3.x/graph/badge.svg?token=2sKMCDNkcl)](https://app.codecov.io/gh/eggjs/egg/tree/3.x)
13
13
  [![Known Vulnerabilities](https://snyk.io/test/npm/egg/badge.svg?style=flat-square)](https://snyk.io/test/npm/egg)
14
14
  [![Open Collective backers and sponsors](https://img.shields.io/opencollective/all/eggjs?style=flat-square)](https://opencollective.com/eggjs)
15
15
 
@@ -1,3 +1,4 @@
1
+ const debug = require('util').debuglog('egg:lib:core:httpclient_next');
1
2
  const ms = require('humanize-ms');
2
3
 
3
4
  const SSRF_HTTPCLIENT = Symbol('SSRF_HTTPCLIENT');
@@ -6,9 +7,17 @@ const mainNodejsVersion = parseInt(process.versions.node.split('.')[0]);
6
7
  let HttpClient;
7
8
  if (mainNodejsVersion >= 18) {
8
9
  // urllib@4 only works on Node.js >= 18
9
- HttpClient = require('urllib4').HttpClient;
10
- } else {
10
+ try {
11
+ HttpClient = require('urllib4').HttpClient;
12
+ debug('urllib4 enable');
13
+ } catch (err) {
14
+ debug('require urllib4 error: %s', err);
15
+ }
16
+ }
17
+ if (!HttpClient) {
18
+ // fallback to urllib@3
11
19
  HttpClient = require('urllib-next').HttpClient;
20
+ debug('urllib3 enable');
12
21
  }
13
22
 
14
23
  class HttpClientNext extends HttpClient {
@@ -26,6 +35,7 @@ class HttpClientNext extends HttpClient {
26
35
  // use on egg-security ssrf
27
36
  // https://github.com/eggjs/egg-security/blob/master/lib/extend/safe_curl.js#L11
28
37
  checkAddress: options.checkAddress,
38
+ connect: options.connect,
29
39
  });
30
40
  this.app = app;
31
41
  }
package/lib/core/utils.js CHANGED
@@ -9,18 +9,28 @@ module.exports = {
9
9
  safeParseURL,
10
10
  };
11
11
 
12
- function convertObject(obj, ignore) {
13
- if (!is.array(ignore)) ignore = [ ignore ];
12
+ function convertObject(obj, ignore, ignoreKeyPaths) {
13
+ if (!is.array(ignore)) {
14
+ ignore = [ ignore ];
15
+ }
16
+ if (!is.array(ignoreKeyPaths)) {
17
+ ignoreKeyPaths = ignoreKeyPaths ? [ ignoreKeyPaths ] : [];
18
+ }
19
+ _convertObject(obj, ignore, ignoreKeyPaths, '');
20
+ }
21
+
22
+ function _convertObject(obj, ignore, ignoreKeyPaths, keyPath) {
14
23
  for (const key of Object.keys(obj)) {
15
- obj[key] = convertValue(key, obj[key], ignore);
24
+ obj[key] = convertValue(key, obj[key], ignore, ignoreKeyPaths, keyPath ? `${keyPath}.${key}` : key);
16
25
  }
17
26
  return obj;
18
27
  }
19
28
 
20
- function convertValue(key, value, ignore) {
29
+ function convertValue(key, value, ignore, ignoreKeyPaths, keyPath) {
21
30
  if (is.nullOrUndefined(value)) return value;
22
31
 
23
32
  let hit = false;
33
+ let hitKeyPath = false;
24
34
  for (const matchKey of ignore) {
25
35
  if (is.string(matchKey) && matchKey === key) {
26
36
  hit = true;
@@ -30,7 +40,13 @@ function convertValue(key, value, ignore) {
30
40
  break;
31
41
  }
32
42
  }
33
- if (!hit) {
43
+ for (const matchKeyPath of ignoreKeyPaths) {
44
+ if (is.string(matchKeyPath) && keyPath === matchKeyPath) {
45
+ hitKeyPath = true;
46
+ break;
47
+ }
48
+ }
49
+ if (!hit && !hitKeyPath) {
34
50
  if (is.symbol(value) || is.regExp(value)) return value.toString();
35
51
  if (is.primitive(value) || is.array(value)) return value;
36
52
  }
@@ -38,7 +54,10 @@ function convertValue(key, value, ignore) {
38
54
  // only convert recursively when it's a plain object,
39
55
  // o = {}
40
56
  if (Object.getPrototypeOf(value) === Object.prototype) {
41
- return convertObject(value, ignore);
57
+ if (hitKeyPath) {
58
+ return '<Object>';
59
+ }
60
+ return _convertObject(value, ignore, ignoreKeyPaths, keyPath);
42
61
  }
43
62
 
44
63
  // support class
package/lib/egg.js CHANGED
@@ -395,8 +395,15 @@ class EggApplication extends EggCore {
395
395
  ignoreList = [];
396
396
  }
397
397
 
398
+ let ignoreKeyPaths;
399
+ try {
400
+ ignoreKeyPaths = this.config.dump.ignoreKeyPaths;
401
+ } catch (e) {
402
+ ignoreKeyPaths = {};
403
+ }
404
+
398
405
  const json = extend(true, {}, { config: this.config, plugins: this.loader.allPlugins, appInfo: this.loader.appInfo });
399
- utils.convertObject(json, ignoreList);
406
+ utils.convertObject(json, ignoreList, ignoreKeyPaths ? Object.keys(ignoreKeyPaths) : []);
400
407
  return {
401
408
  config: json,
402
409
  meta: this.loader.configMeta,
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "egg",
3
- "version": "3.28.0",
3
+ "version": "3.30.0",
4
4
  "publishConfig": {
5
- "tag": "release-3.x",
5
+ "tag": "latest",
6
6
  "access": "public"
7
7
  },
8
8
  "description": "A web framework's framework for Node.js",
@@ -56,7 +56,7 @@
56
56
  "sendmessage": "^2.0.0",
57
57
  "urllib": "^2.33.0",
58
58
  "urllib-next": "npm:urllib@^3.27.1",
59
- "urllib4": "npm:urllib@^4.3.0",
59
+ "urllib4": "npm:urllib@^4.5.0",
60
60
  "utility": "^2.1.0",
61
61
  "ylru": "^1.3.2"
62
62
  },
@@ -79,6 +79,7 @@
79
79
  "eslint": "^8.23.1",
80
80
  "eslint-config-egg": "^12.0.0",
81
81
  "formstream": "^1.1.1",
82
+ "https-pem": "^3.0.0",
82
83
  "jsdoc": "^3.6.11",
83
84
  "koa": "^2.13.4",
84
85
  "koa-static": "^5.0.0",