egg 3.27.1 → 3.29.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/History.md ADDED
@@ -0,0 +1,52 @@
1
+
2
+ 3.29.0 / 2024-11-30
3
+ ==================
4
+
5
+ **features**
6
+ * [[`e4f706990`](http://github.com/eggjs/egg/commit/e4f7069904b99c842e65692f2531a72543719207)] - feat: use urllib@4.5.0 (#5371) (fengmk2 <<fengmk2@gmail.com>>)
7
+
8
+ 3.28.0 / 2024-09-16
9
+ ==================
10
+
11
+ **features**
12
+ * [[`46d3fb222`](http://github.com/eggjs/egg/commit/46d3fb222bcf455d2aee9a99005d18c271f29b16)] - feat: support allowH2 on urllib@4 (#5357) (fengmk2 <<suqian.yf@antgroup.com>>)
13
+
14
+ 3.27.1 / 2024-07-12
15
+ ==================
16
+
17
+ **fixes**
18
+ * [[`f3d8df1b`](http://github.com/eggjs/egg/commit/f3d8df1b7c2aef88cca3beec8c753656f8cc629c)] - fix: add httpclient.safeCurl typing (#5341) (killa <<zhubin.gzb@antgroup.com>>)
19
+
20
+ 3.27.0 / 2024-07-12
21
+ ==================
22
+
23
+ **features**
24
+ * [[`68cbd241`](http://github.com/eggjs/egg/commit/68cbd241e2172b8018328d77ea087dd5974a580f)] - feat: impl httpclient.safeCurl (#5339) (killa <<zhubin.gzb@antgroup.com>>)
25
+
26
+ 3.26.1 / 2024-07-04
27
+ ==================
28
+
29
+ **fixes**
30
+ * [[`872273cb`](http://github.com/eggjs/egg/commit/872273cb23cd6f5d76b3f33528916effade31011)] - fix: xframe value type (#5336) (hongzzz <<hongzzz@foxmail.com>>)
31
+
32
+ **others**
33
+ * [[`8ae76d09`](http://github.com/eggjs/egg/commit/8ae76d09db8cf020cbdacfc64fee0750b9612136)] - docs: fix typo (#5330) (Fu Yuchen <<78291982+fyc09@users.noreply.github.com>>)
34
+
35
+ 3.26.0 / 2024-07-01
36
+ ==================
37
+
38
+ **features**
39
+ * [[`b0292a8b`](http://github.com/eggjs/egg/commit/b0292a8b7e76d5dbf7441b7164c39441dbae51ec)] - feat: allow to create httpClient from app (#5334) (fengmk2 <<suqian.yf@antgroup.com>>)
40
+
41
+ 3.25.0 / 2024-06-27
42
+ ==================
43
+
44
+ **features**
45
+ * [[`ceded0b1`](http://github.com/eggjs/egg/commit/ceded0b1c9217503c5ed9226f96c493d6bd00547)] - feat: allow to httpClient use HTTP2 first (#5332) (fengmk2 <<suqian.yf@antgroup.com>>)
46
+
47
+ **others**
48
+ * [[`8553c3f2`](http://github.com/eggjs/egg/commit/8553c3f23e423e9f60144b11a484b703fe7c9229)] - chore: remove auto release (fengmk2 <<suqian.yf@antgroup.com>>)
49
+ * [[`b4f01a1c`](http://github.com/eggjs/egg/commit/b4f01a1c6bf006c943c85fce334b81d61f55b7d0)] - chore: fix release branches name (fengmk2 <<suqian.yf@antgroup.com>>)
50
+ * [[`a8073b04`](http://github.com/eggjs/egg/commit/a8073b04fc3821bb23326c6c8b4fd0ccaeb5c200)] - chore: add release config (fengmk2 <<suqian.yf@antgroup.com>>)
51
+ * [[`8ce2ff90`](http://github.com/eggjs/egg/commit/8ce2ff90bfbb9e4580a23ea49a15fdb1c185fbb5)] - chore: add npm publish tag (fengmk2 <<suqian.yf@antgroup.com>>)
52
+ * [[`44950ed8`](http://github.com/eggjs/egg/commit/44950ed82a3ce4d5d4b9028aee98d6650298a552)] - chore: start 3.x LTS (fengmk2 <<suqian.yf@antgroup.com>>)
@@ -303,8 +303,8 @@ module.exports = appInfo => {
303
303
  * @property {Number} httpsAgent.freeSocketTimeout - httpss agent socket keepalive max free time, default is 4000 ms.
304
304
  * @property {Number} httpsAgent.maxSockets - https agent max socket number of one host, default is `Number.MAX_SAFE_INTEGER` @ses https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
305
305
  * @property {Number} httpsAgent.maxFreeSockets - https agent max free socket number of one host, default is 256.
306
- * @property {Boolean} useHttpClientNext - use urllib@3 HttpClient
307
- * @property {Boolean} allowH2 - Allow to use HTTP2 first, only work on `useHttpClientNext = true`
306
+ * @property {Boolean} useHttpClientNext - use urllib@3 HttpClient, default is false
307
+ * @property {Boolean} allowH2 - use urllib@4 HttpClient and enable H2, default is false. Only works on Node.js >= 18
308
308
  */
309
309
  config.httpclient = {
310
310
  enableDNSCache: false,
@@ -1,7 +1,25 @@
1
- const { HttpClient } = require('urllib-next');
1
+ const debug = require('util').debuglog('egg:lib:core:httpclient_next');
2
2
  const ms = require('humanize-ms');
3
+
3
4
  const SSRF_HTTPCLIENT = Symbol('SSRF_HTTPCLIENT');
4
5
 
6
+ const mainNodejsVersion = parseInt(process.versions.node.split('.')[0]);
7
+ let HttpClient;
8
+ if (mainNodejsVersion >= 18) {
9
+ // urllib@4 only works on Node.js >= 18
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
19
+ HttpClient = require('urllib-next').HttpClient;
20
+ debug('urllib3 enable');
21
+ }
22
+
5
23
  class HttpClientNext extends HttpClient {
6
24
  constructor(app, options) {
7
25
  normalizeConfig(app);
@@ -17,6 +35,7 @@ class HttpClientNext extends HttpClient {
17
35
  // use on egg-security ssrf
18
36
  // https://github.com/eggjs/egg-security/blob/master/lib/extend/safe_curl.js#L11
19
37
  checkAddress: options.checkAddress,
38
+ connect: options.connect,
20
39
  });
21
40
  this.app = app;
22
41
  }
package/lib/egg.js CHANGED
@@ -292,7 +292,7 @@ class EggApplication extends EggCore {
292
292
  */
293
293
  createHttpClient(options) {
294
294
  let httpClient;
295
- if (this.config.httpclient.useHttpClientNext) {
295
+ if (this.config.httpclient.useHttpClientNext || this.config.httpclient.allowH2) {
296
296
  httpClient = new this.HttpClientNext(this, options);
297
297
  } else if (this.config.httpclient.enableDNSCache) {
298
298
  httpClient = new DNSCacheHttpClient(this, options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "egg",
3
- "version": "3.27.1",
3
+ "version": "3.29.0",
4
4
  "publishConfig": {
5
5
  "tag": "release-3.x",
6
6
  "access": "public"
@@ -55,7 +55,8 @@
55
55
  "onelogger": "^1.0.0",
56
56
  "sendmessage": "^2.0.0",
57
57
  "urllib": "^2.33.0",
58
- "urllib-next": "npm:urllib@^3.26.0",
58
+ "urllib-next": "npm:urllib@^3.27.1",
59
+ "urllib4": "npm:urllib@^4.5.0",
59
60
  "utility": "^2.1.0",
60
61
  "ylru": "^1.3.2"
61
62
  },
@@ -77,19 +78,17 @@
77
78
  "egg-view-nunjucks": "^2.3.0",
78
79
  "eslint": "^8.23.1",
79
80
  "eslint-config-egg": "^12.0.0",
80
- "findlinks": "^2.2.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",
85
86
  "node-libs-browser": "^2.2.1",
86
87
  "pedding": "^1.1.0",
87
88
  "prettier": "^2.7.1",
88
- "puppeteer": "^19.11.1",
89
89
  "react": "^16.14.0",
90
90
  "react-dom": "^16.14.0",
91
91
  "react-router": "^5.3.4",
92
- "runscript": "^1.5.3",
93
92
  "sdk-base": "^4.2.1",
94
93
  "spy": "^1.0.0",
95
94
  "supertest": "^6.2.4",