@openclaw/feishu 2026.7.2-beta.3 → 2026.7.2-beta.4

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.
Files changed (146) hide show
  1. package/dist/api.js +3 -3
  2. package/dist/{app-registration-BzkyrVZu.js → app-registration-cN1bVV6s.js} +5 -5
  3. package/dist/{channel-BdnXYU6g.js → channel-DB1x6UJX.js} +15 -8
  4. package/dist/channel-plugin-api.js +1 -1
  5. package/dist/{channel.runtime-CVIzo2dV.js → channel.runtime-B5yAAvbT.js} +5 -5
  6. package/dist/{client-87BmeMpj.js → client-Dee7cKsS.js} +62 -1
  7. package/dist/{doctor-contract-DXH5hux1.js → doctor-contract-Cw5sdjOm.js} +29 -41
  8. package/dist/doctor-contract-api.js +1 -1
  9. package/dist/{drive-BHv8WW9i.js → drive-_zrcOxzS.js} +1 -1
  10. package/dist/{send-DcrXbqqA.js → media-CRJunSRr.js} +1048 -1019
  11. package/dist/{monitor-BVQf7-Bl.js → monitor-8CLu6myv.js} +5 -4
  12. package/dist/{monitor.account-Blbf2T6J.js → monitor.account-CkYj45PC.js} +1563 -589
  13. package/dist/monitor.startup-CSUPT_U1.js +143 -0
  14. package/dist/{probe-BgboTHIn.js → probe-Za1kgUvx.js} +70 -10
  15. package/dist/setup-api.js +1 -1
  16. package/node_modules/@larksuiteoapi/node-sdk/README.md +13 -0
  17. package/node_modules/@larksuiteoapi/node-sdk/README.zh.md +12 -0
  18. package/node_modules/@larksuiteoapi/node-sdk/es/index.js +8950 -3084
  19. package/node_modules/@larksuiteoapi/node-sdk/lib/index.js +8951 -3083
  20. package/node_modules/@larksuiteoapi/node-sdk/package.json +1 -1
  21. package/node_modules/@larksuiteoapi/node-sdk/types/index.d.ts +12522 -698
  22. package/node_modules/@protobufjs/utf8/CHANGELOG.md +8 -0
  23. package/node_modules/@protobufjs/utf8/index.js +29 -18
  24. package/node_modules/@protobufjs/utf8/package.json +2 -2
  25. package/node_modules/@protobufjs/utf8/tests/index.js +5 -0
  26. package/node_modules/@types/node/README.md +1 -1
  27. package/node_modules/@types/node/fs/promises.d.ts +16 -6
  28. package/node_modules/@types/node/package.json +2 -2
  29. package/node_modules/agent-base/README.md +145 -0
  30. package/node_modules/agent-base/dist/src/index.d.ts +78 -0
  31. package/node_modules/agent-base/dist/src/index.js +203 -0
  32. package/node_modules/agent-base/dist/src/index.js.map +1 -0
  33. package/node_modules/agent-base/dist/src/promisify.d.ts +4 -0
  34. package/node_modules/agent-base/dist/src/promisify.js +18 -0
  35. package/node_modules/agent-base/dist/src/promisify.js.map +1 -0
  36. package/node_modules/agent-base/package.json +64 -0
  37. package/node_modules/agent-base/src/index.ts +345 -0
  38. package/node_modules/agent-base/src/promisify.ts +33 -0
  39. package/node_modules/axios/CHANGELOG.md +197 -1
  40. package/node_modules/axios/README.md +424 -256
  41. package/node_modules/axios/dist/axios.js +589 -204
  42. package/node_modules/axios/dist/axios.min.js +3 -3
  43. package/node_modules/axios/dist/axios.min.js.map +1 -1
  44. package/node_modules/axios/dist/browser/axios.cjs +630 -185
  45. package/node_modules/axios/dist/esm/axios.js +630 -185
  46. package/node_modules/axios/dist/esm/axios.min.js +2 -2
  47. package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
  48. package/node_modules/axios/dist/node/axios.cjs +949 -301
  49. package/node_modules/axios/index.d.cts +28 -5
  50. package/node_modules/axios/index.d.ts +24 -3
  51. package/node_modules/axios/lib/adapters/adapters.js +1 -1
  52. package/node_modules/axios/lib/adapters/fetch.js +223 -49
  53. package/node_modules/axios/lib/adapters/http.js +408 -193
  54. package/node_modules/axios/lib/adapters/xhr.js +3 -1
  55. package/node_modules/axios/lib/core/Axios.js +4 -2
  56. package/node_modules/axios/lib/core/AxiosError.js +13 -1
  57. package/node_modules/axios/lib/core/AxiosHeaders.js +13 -42
  58. package/node_modules/axios/lib/core/buildFullPath.js +29 -1
  59. package/node_modules/axios/lib/core/mergeConfig.js +35 -0
  60. package/node_modules/axios/lib/defaults/transitional.js +2 -0
  61. package/node_modules/axios/lib/env/data.js +1 -1
  62. package/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +1 -3
  63. package/node_modules/axios/lib/helpers/Http2Sessions.js +119 -0
  64. package/node_modules/axios/lib/helpers/buildURL.js +7 -4
  65. package/node_modules/axios/lib/helpers/composeSignals.js +48 -47
  66. package/node_modules/axios/lib/helpers/cookies.js +5 -1
  67. package/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +16 -11
  68. package/node_modules/axios/lib/helpers/formDataToJSON.js +26 -4
  69. package/node_modules/axios/lib/helpers/formDataToStream.js +2 -2
  70. package/node_modules/axios/lib/helpers/fromDataURI.js +20 -5
  71. package/node_modules/axios/lib/helpers/progressEventReducer.js +3 -0
  72. package/node_modules/axios/lib/helpers/resolveConfig.js +26 -13
  73. package/node_modules/axios/lib/helpers/sanitizeHeaderValue.js +60 -0
  74. package/node_modules/axios/lib/helpers/shouldBypassProxy.js +33 -1
  75. package/node_modules/axios/lib/helpers/toFormData.js +48 -12
  76. package/node_modules/axios/lib/helpers/validator.js +1 -1
  77. package/node_modules/axios/lib/utils.js +105 -19
  78. package/node_modules/axios/package.json +31 -13
  79. package/node_modules/https-proxy-agent/README.md +137 -0
  80. package/node_modules/https-proxy-agent/dist/agent.d.ts +30 -0
  81. package/node_modules/https-proxy-agent/dist/agent.js +177 -0
  82. package/node_modules/https-proxy-agent/dist/agent.js.map +1 -0
  83. package/node_modules/https-proxy-agent/dist/index.d.ts +23 -0
  84. package/node_modules/https-proxy-agent/dist/index.js +14 -0
  85. package/node_modules/https-proxy-agent/dist/index.js.map +1 -0
  86. package/node_modules/https-proxy-agent/dist/parse-proxy-response.d.ts +7 -0
  87. package/node_modules/https-proxy-agent/dist/parse-proxy-response.js +66 -0
  88. package/node_modules/https-proxy-agent/dist/parse-proxy-response.js.map +1 -0
  89. package/node_modules/https-proxy-agent/package.json +56 -0
  90. package/node_modules/protobufjs/dist/light/protobuf.js +145 -188
  91. package/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
  92. package/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
  93. package/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
  94. package/node_modules/protobufjs/dist/minimal/protobuf.js +33 -76
  95. package/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
  96. package/node_modules/protobufjs/dist/minimal/protobuf.min.js +3 -3
  97. package/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
  98. package/node_modules/protobufjs/dist/protobuf.js +168 -208
  99. package/node_modules/protobufjs/dist/protobuf.js.map +1 -1
  100. package/node_modules/protobufjs/dist/protobuf.min.js +3 -3
  101. package/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
  102. package/node_modules/protobufjs/index.d.ts +0 -8
  103. package/node_modules/protobufjs/package.json +2 -3
  104. package/node_modules/protobufjs/src/parse.js +3 -0
  105. package/node_modules/protobufjs/src/util/minimal.js +0 -3
  106. package/node_modules/qs/CHANGELOG.md +11 -0
  107. package/node_modules/qs/dist/qs.js +17 -17
  108. package/node_modules/qs/lib/parse.js +19 -8
  109. package/node_modules/qs/lib/utils.js +47 -8
  110. package/node_modules/qs/package.json +6 -5
  111. package/node_modules/qs/test/parse.js +230 -0
  112. package/node_modules/qs/test/utils.js +194 -0
  113. package/node_modules/typebox/build/compile/validator.d.mts +1 -4
  114. package/node_modules/typebox/build/guard/guard.d.mts +1 -1
  115. package/node_modules/typebox/build/guard/guard.mjs +5 -2
  116. package/node_modules/typebox/build/guard/string.mjs +16 -4
  117. package/node_modules/typebox/build/schema/engine/_functions.mjs +34 -15
  118. package/node_modules/typebox/build/type/action/readonly_object.d.mts +5 -0
  119. package/node_modules/typebox/build/type/action/readonly_object.mjs +8 -0
  120. package/node_modules/typebox/build/typebox.d.mts +1 -1
  121. package/node_modules/typebox/build/typebox.mjs +1 -1
  122. package/node_modules/typebox/package.json +1 -1
  123. package/node_modules/typebox/readme.md +29 -32
  124. package/node_modules/ws/lib/receiver.js +15 -32
  125. package/node_modules/ws/lib/websocket-server.js +4 -4
  126. package/node_modules/ws/lib/websocket.js +4 -4
  127. package/node_modules/ws/package.json +5 -1
  128. package/npm-shrinkwrap.json +58 -38
  129. package/openclaw.plugin.json +2 -10
  130. package/package.json +20 -7
  131. package/dist/monitor.startup-Cy8NPGAX.js +0 -43
  132. package/node_modules/@protobufjs/inquire/CHANGELOG.md +0 -8
  133. package/node_modules/@protobufjs/inquire/LICENSE +0 -26
  134. package/node_modules/@protobufjs/inquire/README.md +0 -13
  135. package/node_modules/@protobufjs/inquire/index.d.ts +0 -10
  136. package/node_modules/@protobufjs/inquire/index.js +0 -38
  137. package/node_modules/@protobufjs/inquire/package.json +0 -21
  138. package/node_modules/@protobufjs/inquire/tests/data/array.js +0 -1
  139. package/node_modules/@protobufjs/inquire/tests/data/emptyArray.js +0 -1
  140. package/node_modules/@protobufjs/inquire/tests/data/emptyObject.js +0 -1
  141. package/node_modules/@protobufjs/inquire/tests/data/object.js +0 -1
  142. package/node_modules/@protobufjs/inquire/tests/index.js +0 -20
  143. package/node_modules/axios/dist/axios.js.map +0 -1
  144. package/node_modules/axios/dist/browser/axios.cjs.map +0 -1
  145. package/node_modules/axios/dist/esm/axios.js.map +0 -1
  146. package/node_modules/axios/dist/node/axios.cjs.map +0 -1
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ ## [1.1.2](https://github.com/protobufjs/protobuf.js/compare/utf8-v1.1.1...utf8-v1.1.2) (2026-07-05)
4
+
5
+
6
+ ### Performance Improvements
7
+
8
+ * Batch String.fromCharCode in @protobufjs/utf8 read ([#2355](https://github.com/protobufjs/protobuf.js/issues/2355)) ([d1ae3ce](https://github.com/protobufjs/protobuf.js/commit/d1ae3ce46370254ada0f3db689506a9139c8d1ee))
@@ -6,7 +6,7 @@
6
6
  * @namespace
7
7
  */
8
8
  var utf8 = exports,
9
- replacementChar = "\ufffd";
9
+ replacementCharCode = 0xFFFD; // U+FFFD REPLACEMENT CHARACTER
10
10
 
11
11
  /**
12
12
  * Calculates the UTF8 byte length of a string.
@@ -39,34 +39,45 @@ utf8.length = function utf8_length(string) {
39
39
  * @returns {string} String read
40
40
  */
41
41
  utf8.read = function utf8_read(buffer, start, end) {
42
- if (end - start < 1) {
42
+ if (end - start < 1)
43
43
  return "";
44
- }
45
-
46
- var str = "";
47
- for (var i = start; i < end;) {
48
- var t = buffer[i++];
44
+ // Batch code units and flush via String.fromCharCode.apply in 8192-unit
45
+ // chunks to avoid the per-character ConsString buildup of `str += ...`.
46
+ var parts = null,
47
+ chunk = [],
48
+ i = 0, // chunk write index
49
+ t, t2, c2, c3;
50
+ while (start < end) {
51
+ t = buffer[start++];
49
52
  if (t <= 0x7F) {
50
- str += String.fromCharCode(t);
53
+ chunk[i++] = t;
51
54
  } else if (t >= 0xC0 && t < 0xE0) {
52
- var c2 = (t & 0x1F) << 6 | buffer[i++] & 0x3F;
53
- str += c2 >= 0x80 ? String.fromCharCode(c2) : replacementChar;
55
+ c2 = (t & 0x1F) << 6 | buffer[start++] & 0x3F;
56
+ chunk[i++] = c2 >= 0x80 ? c2 : replacementCharCode;
54
57
  } else if (t >= 0xE0 && t < 0xF0) {
55
- var c3 = (t & 0xF) << 12 | (buffer[i++] & 0x3F) << 6 | buffer[i++] & 0x3F;
56
- str += c3 >= 0x800 ? String.fromCharCode(c3) : replacementChar;
58
+ c3 = (t & 0xF) << 12 | (buffer[start++] & 0x3F) << 6 | buffer[start++] & 0x3F;
59
+ chunk[i++] = c3 >= 0x800 ? c3 : replacementCharCode;
57
60
  } else if (t >= 0xF0) {
58
- var t2 = (t & 7) << 18 | (buffer[i++] & 0x3F) << 12 | (buffer[i++] & 0x3F) << 6 | buffer[i++] & 0x3F;
61
+ t2 = (t & 7) << 18 | (buffer[start++] & 0x3F) << 12 | (buffer[start++] & 0x3F) << 6 | buffer[start++] & 0x3F;
59
62
  if (t2 < 0x10000 || t2 > 0x10FFFF)
60
- str += replacementChar;
63
+ chunk[i++] = replacementCharCode;
61
64
  else {
62
65
  t2 -= 0x10000;
63
- str += String.fromCharCode(0xD800 + (t2 >> 10));
64
- str += String.fromCharCode(0xDC00 + (t2 & 0x3FF));
66
+ chunk[i++] = 0xD800 + (t2 >> 10);
67
+ chunk[i++] = 0xDC00 + (t2 & 0x3FF);
65
68
  }
66
69
  }
70
+ if (i > 8191) {
71
+ (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk.slice(0, i)));
72
+ i = 0;
73
+ }
67
74
  }
68
-
69
- return str;
75
+ if (parts) {
76
+ if (i)
77
+ parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
78
+ return parts.join("");
79
+ }
80
+ return String.fromCharCode.apply(String, chunk.slice(0, i));
70
81
  };
71
82
 
72
83
  /**
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@protobufjs/utf8",
3
3
  "description": "A minimal UTF8 implementation for number arrays.",
4
- "version": "1.1.1",
4
+ "version": "1.1.2",
5
5
  "author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "https://github.com/dcodeIO/protobuf.js.git"
8
+ "url": "https://github.com/protobufjs/protobuf.js.git"
9
9
  },
10
10
  "license": "BSD-3-Clause",
11
11
  "main": "index.js",
@@ -47,6 +47,11 @@ tape.test("utf8", function(test) {
47
47
  test.equal(comp, "\ufffd", "should decode overlong UTF-8 sequences as replacement characters");
48
48
  });
49
49
 
50
+ var longMultibyteStr = "\u20ac\u00df\u7a7a\u03bb\ud835\udd4f".repeat(20000); // 3-byte, 2-byte and surrogate-pair code points
51
+ var longMultibyte = Buffer.from(longMultibyteStr, "utf8");
52
+ comp = utf8.read(longMultibyte, 0, longMultibyte.length);
53
+ test.equal(comp, longMultibyteStr, "should decode a large multibyte string spanning many flush boundaries");
54
+
50
55
  test.end();
51
56
  });
52
57
 
@@ -8,7 +8,7 @@ This package contains type definitions for node (https://nodejs.org/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Wed, 01 Jul 2026 11:03:38 GMT
11
+ * Last updated: Wed, 08 Jul 2026 06:47:45 GMT
12
12
  * Dependencies: [undici-types](https://npmjs.com/package/undici-types)
13
13
 
14
14
  # Credits
@@ -153,7 +153,11 @@ declare module "node:fs/promises" {
153
153
  * @return Fulfills with `undefined` upon success.
154
154
  */
155
155
  appendFile(
156
- data: string | Uint8Array,
156
+ data:
157
+ | string
158
+ | NodeJS.ArrayBufferView
159
+ | Iterable<string | NodeJS.ArrayBufferView>
160
+ | AsyncIterable<string | NodeJS.ArrayBufferView>,
157
161
  options?:
158
162
  | (ObjectEncodingOptions & Abortable)
159
163
  | BufferEncoding
@@ -470,7 +474,11 @@ declare module "node:fs/promises" {
470
474
  * @since v10.0.0
471
475
  */
472
476
  writeFile(
473
- data: string | Uint8Array,
477
+ data:
478
+ | string
479
+ | NodeJS.ArrayBufferView
480
+ | Iterable<string | NodeJS.ArrayBufferView>
481
+ | AsyncIterable<string | NodeJS.ArrayBufferView>,
474
482
  options?:
475
483
  | (ObjectEncodingOptions & Abortable)
476
484
  | BufferEncoding
@@ -1208,8 +1216,7 @@ declare module "node:fs/promises" {
1208
1216
  | string
1209
1217
  | NodeJS.ArrayBufferView
1210
1218
  | Iterable<string | NodeJS.ArrayBufferView>
1211
- | AsyncIterable<string | NodeJS.ArrayBufferView>
1212
- | Stream,
1219
+ | AsyncIterable<string | NodeJS.ArrayBufferView>,
1213
1220
  options?:
1214
1221
  | (ObjectEncodingOptions & {
1215
1222
  mode?: Mode | undefined;
@@ -1240,7 +1247,11 @@ declare module "node:fs/promises" {
1240
1247
  */
1241
1248
  function appendFile(
1242
1249
  path: PathLike | FileHandle,
1243
- data: string | Uint8Array,
1250
+ data:
1251
+ | string
1252
+ | NodeJS.ArrayBufferView
1253
+ | Iterable<string | NodeJS.ArrayBufferView>
1254
+ | AsyncIterable<string | NodeJS.ArrayBufferView>,
1244
1255
  options?: (ObjectEncodingOptions & FlagAndOpenMode & { flush?: boolean | undefined }) | BufferEncoding | null,
1245
1256
  ): Promise<void>;
1246
1257
  /**
@@ -1432,7 +1443,6 @@ declare module "node:fs/promises" {
1432
1443
  * When copying a directory to another directory, globs are not supported and
1433
1444
  * behavior is similar to `cp dir1/ dir2/`.
1434
1445
  * @since v16.7.0
1435
- * @experimental
1436
1446
  * @param src source path to copy.
1437
1447
  * @param dest destination path to copy to.
1438
1448
  * @return Fulfills with `undefined` upon success.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "26.1.0",
3
+ "version": "26.1.1",
4
4
  "description": "TypeScript definitions for node",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -150,6 +150,6 @@
150
150
  "undici-types": "~8.3.0"
151
151
  },
152
152
  "peerDependencies": {},
153
- "typesPublisherContentHash": "bac6fe2369bbd2e0f2cf6643373e8c398ed66b886a72749c8d1fb0b9b60031ab",
153
+ "typesPublisherContentHash": "a59119b073061829bc67a5bf6bc2b8ecb0a5a6196058e3c73172a00440f4e16d",
154
154
  "typeScriptVersion": "5.6"
155
155
  }
@@ -0,0 +1,145 @@
1
+ agent-base
2
+ ==========
3
+ ### Turn a function into an [`http.Agent`][http.Agent] instance
4
+ [![Build Status](https://github.com/TooTallNate/node-agent-base/workflows/Node%20CI/badge.svg)](https://github.com/TooTallNate/node-agent-base/actions?workflow=Node+CI)
5
+
6
+ This module provides an `http.Agent` generator. That is, you pass it an async
7
+ callback function, and it returns a new `http.Agent` instance that will invoke the
8
+ given callback function when sending outbound HTTP requests.
9
+
10
+ #### Some subclasses:
11
+
12
+ Here's some more interesting uses of `agent-base`.
13
+ Send a pull request to list yours!
14
+
15
+ * [`http-proxy-agent`][http-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTP endpoints
16
+ * [`https-proxy-agent`][https-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTPS endpoints
17
+ * [`pac-proxy-agent`][pac-proxy-agent]: A PAC file proxy `http.Agent` implementation for HTTP and HTTPS
18
+ * [`socks-proxy-agent`][socks-proxy-agent]: A SOCKS proxy `http.Agent` implementation for HTTP and HTTPS
19
+
20
+
21
+ Installation
22
+ ------------
23
+
24
+ Install with `npm`:
25
+
26
+ ``` bash
27
+ $ npm install agent-base
28
+ ```
29
+
30
+
31
+ Example
32
+ -------
33
+
34
+ Here's a minimal example that creates a new `net.Socket` connection to the server
35
+ for every HTTP request (i.e. the equivalent of `agent: false` option):
36
+
37
+ ```js
38
+ var net = require('net');
39
+ var tls = require('tls');
40
+ var url = require('url');
41
+ var http = require('http');
42
+ var agent = require('agent-base');
43
+
44
+ var endpoint = 'http://nodejs.org/api/';
45
+ var parsed = url.parse(endpoint);
46
+
47
+ // This is the important part!
48
+ parsed.agent = agent(function (req, opts) {
49
+ var socket;
50
+ // `secureEndpoint` is true when using the https module
51
+ if (opts.secureEndpoint) {
52
+ socket = tls.connect(opts);
53
+ } else {
54
+ socket = net.connect(opts);
55
+ }
56
+ return socket;
57
+ });
58
+
59
+ // Everything else works just like normal...
60
+ http.get(parsed, function (res) {
61
+ console.log('"response" event!', res.headers);
62
+ res.pipe(process.stdout);
63
+ });
64
+ ```
65
+
66
+ Returning a Promise or using an `async` function is also supported:
67
+
68
+ ```js
69
+ agent(async function (req, opts) {
70
+ await sleep(1000);
71
+ // etc…
72
+ });
73
+ ```
74
+
75
+ Return another `http.Agent` instance to "pass through" the responsibility
76
+ for that HTTP request to that agent:
77
+
78
+ ```js
79
+ agent(function (req, opts) {
80
+ return opts.secureEndpoint ? https.globalAgent : http.globalAgent;
81
+ });
82
+ ```
83
+
84
+
85
+ API
86
+ ---
87
+
88
+ ## Agent(Function callback[, Object options]) → [http.Agent][]
89
+
90
+ Creates a base `http.Agent` that will execute the callback function `callback`
91
+ for every HTTP request that it is used as the `agent` for. The callback function
92
+ is responsible for creating a `stream.Duplex` instance of some kind that will be
93
+ used as the underlying socket in the HTTP request.
94
+
95
+ The `options` object accepts the following properties:
96
+
97
+ * `timeout` - Number - Timeout for the `callback()` function in milliseconds. Defaults to Infinity (optional).
98
+
99
+ The callback function should have the following signature:
100
+
101
+ ### callback(http.ClientRequest req, Object options, Function cb) → undefined
102
+
103
+ The ClientRequest `req` can be accessed to read request headers and
104
+ and the path, etc. The `options` object contains the options passed
105
+ to the `http.request()`/`https.request()` function call, and is formatted
106
+ to be directly passed to `net.connect()`/`tls.connect()`, or however
107
+ else you want a Socket to be created. Pass the created socket to
108
+ the callback function `cb` once created, and the HTTP request will
109
+ continue to proceed.
110
+
111
+ If the `https` module is used to invoke the HTTP request, then the
112
+ `secureEndpoint` property on `options` _will be set to `true`_.
113
+
114
+
115
+ License
116
+ -------
117
+
118
+ (The MIT License)
119
+
120
+ Copyright (c) 2013 Nathan Rajlich &lt;nathan@tootallnate.net&gt;
121
+
122
+ Permission is hereby granted, free of charge, to any person obtaining
123
+ a copy of this software and associated documentation files (the
124
+ 'Software'), to deal in the Software without restriction, including
125
+ without limitation the rights to use, copy, modify, merge, publish,
126
+ distribute, sublicense, and/or sell copies of the Software, and to
127
+ permit persons to whom the Software is furnished to do so, subject to
128
+ the following conditions:
129
+
130
+ The above copyright notice and this permission notice shall be
131
+ included in all copies or substantial portions of the Software.
132
+
133
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
134
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
135
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
136
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
137
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
138
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
139
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
140
+
141
+ [http-proxy-agent]: https://github.com/TooTallNate/node-http-proxy-agent
142
+ [https-proxy-agent]: https://github.com/TooTallNate/node-https-proxy-agent
143
+ [pac-proxy-agent]: https://github.com/TooTallNate/node-pac-proxy-agent
144
+ [socks-proxy-agent]: https://github.com/TooTallNate/node-socks-proxy-agent
145
+ [http.Agent]: https://nodejs.org/api/http.html#http_class_http_agent
@@ -0,0 +1,78 @@
1
+ /// <reference types="node" />
2
+ import net from 'net';
3
+ import http from 'http';
4
+ import https from 'https';
5
+ import { Duplex } from 'stream';
6
+ import { EventEmitter } from 'events';
7
+ declare function createAgent(opts?: createAgent.AgentOptions): createAgent.Agent;
8
+ declare function createAgent(callback: createAgent.AgentCallback, opts?: createAgent.AgentOptions): createAgent.Agent;
9
+ declare namespace createAgent {
10
+ interface ClientRequest extends http.ClientRequest {
11
+ _last?: boolean;
12
+ _hadError?: boolean;
13
+ method: string;
14
+ }
15
+ interface AgentRequestOptions {
16
+ host?: string;
17
+ path?: string;
18
+ port: number;
19
+ }
20
+ interface HttpRequestOptions extends AgentRequestOptions, Omit<http.RequestOptions, keyof AgentRequestOptions> {
21
+ secureEndpoint: false;
22
+ }
23
+ interface HttpsRequestOptions extends AgentRequestOptions, Omit<https.RequestOptions, keyof AgentRequestOptions> {
24
+ secureEndpoint: true;
25
+ }
26
+ type RequestOptions = HttpRequestOptions | HttpsRequestOptions;
27
+ type AgentLike = Pick<createAgent.Agent, 'addRequest'> | http.Agent;
28
+ type AgentCallbackReturn = Duplex | AgentLike;
29
+ type AgentCallbackCallback = (err?: Error | null, socket?: createAgent.AgentCallbackReturn) => void;
30
+ type AgentCallbackPromise = (req: createAgent.ClientRequest, opts: createAgent.RequestOptions) => createAgent.AgentCallbackReturn | Promise<createAgent.AgentCallbackReturn>;
31
+ type AgentCallback = typeof Agent.prototype.callback;
32
+ type AgentOptions = {
33
+ timeout?: number;
34
+ };
35
+ /**
36
+ * Base `http.Agent` implementation.
37
+ * No pooling/keep-alive is implemented by default.
38
+ *
39
+ * @param {Function} callback
40
+ * @api public
41
+ */
42
+ class Agent extends EventEmitter {
43
+ timeout: number | null;
44
+ maxFreeSockets: number;
45
+ maxTotalSockets: number;
46
+ maxSockets: number;
47
+ sockets: {
48
+ [key: string]: net.Socket[];
49
+ };
50
+ freeSockets: {
51
+ [key: string]: net.Socket[];
52
+ };
53
+ requests: {
54
+ [key: string]: http.IncomingMessage[];
55
+ };
56
+ options: https.AgentOptions;
57
+ private promisifiedCallback?;
58
+ private explicitDefaultPort?;
59
+ private explicitProtocol?;
60
+ constructor(callback?: createAgent.AgentCallback | createAgent.AgentOptions, _opts?: createAgent.AgentOptions);
61
+ get defaultPort(): number;
62
+ set defaultPort(v: number);
63
+ get protocol(): string;
64
+ set protocol(v: string);
65
+ callback(req: createAgent.ClientRequest, opts: createAgent.RequestOptions, fn: createAgent.AgentCallbackCallback): void;
66
+ callback(req: createAgent.ClientRequest, opts: createAgent.RequestOptions): createAgent.AgentCallbackReturn | Promise<createAgent.AgentCallbackReturn>;
67
+ /**
68
+ * Called by node-core's "_http_client.js" module when creating
69
+ * a new HTTP request with this Agent instance.
70
+ *
71
+ * @api public
72
+ */
73
+ addRequest(req: ClientRequest, _opts: RequestOptions): void;
74
+ freeSocket(socket: net.Socket, opts: AgentOptions): void;
75
+ destroy(): void;
76
+ }
77
+ }
78
+ export = createAgent;
@@ -0,0 +1,203 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ const events_1 = require("events");
6
+ const debug_1 = __importDefault(require("debug"));
7
+ const promisify_1 = __importDefault(require("./promisify"));
8
+ const debug = debug_1.default('agent-base');
9
+ function isAgent(v) {
10
+ return Boolean(v) && typeof v.addRequest === 'function';
11
+ }
12
+ function isSecureEndpoint() {
13
+ const { stack } = new Error();
14
+ if (typeof stack !== 'string')
15
+ return false;
16
+ return stack.split('\n').some(l => l.indexOf('(https.js:') !== -1 || l.indexOf('node:https:') !== -1);
17
+ }
18
+ function createAgent(callback, opts) {
19
+ return new createAgent.Agent(callback, opts);
20
+ }
21
+ (function (createAgent) {
22
+ /**
23
+ * Base `http.Agent` implementation.
24
+ * No pooling/keep-alive is implemented by default.
25
+ *
26
+ * @param {Function} callback
27
+ * @api public
28
+ */
29
+ class Agent extends events_1.EventEmitter {
30
+ constructor(callback, _opts) {
31
+ super();
32
+ let opts = _opts;
33
+ if (typeof callback === 'function') {
34
+ this.callback = callback;
35
+ }
36
+ else if (callback) {
37
+ opts = callback;
38
+ }
39
+ // Timeout for the socket to be returned from the callback
40
+ this.timeout = null;
41
+ if (opts && typeof opts.timeout === 'number') {
42
+ this.timeout = opts.timeout;
43
+ }
44
+ // These aren't actually used by `agent-base`, but are required
45
+ // for the TypeScript definition files in `@types/node` :/
46
+ this.maxFreeSockets = 1;
47
+ this.maxSockets = 1;
48
+ this.maxTotalSockets = Infinity;
49
+ this.sockets = {};
50
+ this.freeSockets = {};
51
+ this.requests = {};
52
+ this.options = {};
53
+ }
54
+ get defaultPort() {
55
+ if (typeof this.explicitDefaultPort === 'number') {
56
+ return this.explicitDefaultPort;
57
+ }
58
+ return isSecureEndpoint() ? 443 : 80;
59
+ }
60
+ set defaultPort(v) {
61
+ this.explicitDefaultPort = v;
62
+ }
63
+ get protocol() {
64
+ if (typeof this.explicitProtocol === 'string') {
65
+ return this.explicitProtocol;
66
+ }
67
+ return isSecureEndpoint() ? 'https:' : 'http:';
68
+ }
69
+ set protocol(v) {
70
+ this.explicitProtocol = v;
71
+ }
72
+ callback(req, opts, fn) {
73
+ throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`');
74
+ }
75
+ /**
76
+ * Called by node-core's "_http_client.js" module when creating
77
+ * a new HTTP request with this Agent instance.
78
+ *
79
+ * @api public
80
+ */
81
+ addRequest(req, _opts) {
82
+ const opts = Object.assign({}, _opts);
83
+ if (typeof opts.secureEndpoint !== 'boolean') {
84
+ opts.secureEndpoint = isSecureEndpoint();
85
+ }
86
+ if (opts.host == null) {
87
+ opts.host = 'localhost';
88
+ }
89
+ if (opts.port == null) {
90
+ opts.port = opts.secureEndpoint ? 443 : 80;
91
+ }
92
+ if (opts.protocol == null) {
93
+ opts.protocol = opts.secureEndpoint ? 'https:' : 'http:';
94
+ }
95
+ if (opts.host && opts.path) {
96
+ // If both a `host` and `path` are specified then it's most
97
+ // likely the result of a `url.parse()` call... we need to
98
+ // remove the `path` portion so that `net.connect()` doesn't
99
+ // attempt to open that as a unix socket file.
100
+ delete opts.path;
101
+ }
102
+ delete opts.agent;
103
+ delete opts.hostname;
104
+ delete opts._defaultAgent;
105
+ delete opts.defaultPort;
106
+ delete opts.createConnection;
107
+ // Hint to use "Connection: close"
108
+ // XXX: non-documented `http` module API :(
109
+ req._last = true;
110
+ req.shouldKeepAlive = false;
111
+ let timedOut = false;
112
+ let timeoutId = null;
113
+ const timeoutMs = opts.timeout || this.timeout;
114
+ const onerror = (err) => {
115
+ if (req._hadError)
116
+ return;
117
+ req.emit('error', err);
118
+ // For Safety. Some additional errors might fire later on
119
+ // and we need to make sure we don't double-fire the error event.
120
+ req._hadError = true;
121
+ };
122
+ const ontimeout = () => {
123
+ timeoutId = null;
124
+ timedOut = true;
125
+ const err = new Error(`A "socket" was not created for HTTP request before ${timeoutMs}ms`);
126
+ err.code = 'ETIMEOUT';
127
+ onerror(err);
128
+ };
129
+ const callbackError = (err) => {
130
+ if (timedOut)
131
+ return;
132
+ if (timeoutId !== null) {
133
+ clearTimeout(timeoutId);
134
+ timeoutId = null;
135
+ }
136
+ onerror(err);
137
+ };
138
+ const onsocket = (socket) => {
139
+ if (timedOut)
140
+ return;
141
+ if (timeoutId != null) {
142
+ clearTimeout(timeoutId);
143
+ timeoutId = null;
144
+ }
145
+ if (isAgent(socket)) {
146
+ // `socket` is actually an `http.Agent` instance, so
147
+ // relinquish responsibility for this `req` to the Agent
148
+ // from here on
149
+ debug('Callback returned another Agent instance %o', socket.constructor.name);
150
+ socket.addRequest(req, opts);
151
+ return;
152
+ }
153
+ if (socket) {
154
+ socket.once('free', () => {
155
+ this.freeSocket(socket, opts);
156
+ });
157
+ req.onSocket(socket);
158
+ return;
159
+ }
160
+ const err = new Error(`no Duplex stream was returned to agent-base for \`${req.method} ${req.path}\``);
161
+ onerror(err);
162
+ };
163
+ if (typeof this.callback !== 'function') {
164
+ onerror(new Error('`callback` is not defined'));
165
+ return;
166
+ }
167
+ if (!this.promisifiedCallback) {
168
+ if (this.callback.length >= 3) {
169
+ debug('Converting legacy callback function to promise');
170
+ this.promisifiedCallback = promisify_1.default(this.callback);
171
+ }
172
+ else {
173
+ this.promisifiedCallback = this.callback;
174
+ }
175
+ }
176
+ if (typeof timeoutMs === 'number' && timeoutMs > 0) {
177
+ timeoutId = setTimeout(ontimeout, timeoutMs);
178
+ }
179
+ if ('port' in opts && typeof opts.port !== 'number') {
180
+ opts.port = Number(opts.port);
181
+ }
182
+ try {
183
+ debug('Resolving socket for %o request: %o', opts.protocol, `${req.method} ${req.path}`);
184
+ Promise.resolve(this.promisifiedCallback(req, opts)).then(onsocket, callbackError);
185
+ }
186
+ catch (err) {
187
+ Promise.reject(err).catch(callbackError);
188
+ }
189
+ }
190
+ freeSocket(socket, opts) {
191
+ debug('Freeing socket %o %o', socket.constructor.name, opts);
192
+ socket.destroy();
193
+ }
194
+ destroy() {
195
+ debug('Destroying agent %o', this.constructor.name);
196
+ }
197
+ }
198
+ createAgent.Agent = Agent;
199
+ // So that `instanceof` works correctly
200
+ createAgent.prototype = createAgent.Agent.prototype;
201
+ })(createAgent || (createAgent = {}));
202
+ module.exports = createAgent;
203
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAIA,mCAAsC;AACtC,kDAAgC;AAChC,4DAAoC;AAEpC,MAAM,KAAK,GAAG,eAAW,CAAC,YAAY,CAAC,CAAC;AAExC,SAAS,OA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AC;aACzC;QACF,CAAC;QAED,UAAU,CAAC,MAAkB,EAAE,IAAkB;YAChD,KAAK,CAAC,sBAAsB,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC7D,MAAM,CAAC,OAAO,EAAE,CAAC;QAClB,CAAC;QAED,OAAO;YACN,KAAK,CAAC,qBAAqB,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACrD,CAAC;KACD;IAxPY,iBAAK,QAwPjB,CAAA;IAED,uCAAuC;IACvC,WAAW,CAAC,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC;AACrD,CAAC,EAtTS,WAAW,KAAX,WAAW,QAsTpB;AAED,iBAAS,WAAW,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { ClientRequest, RequestOptions, AgentCallbackCallback, AgentCallbackPromise } from './index';
2
+ declare type LegacyCallback = (req: ClientRequest, opts: RequestOptions, fn: AgentCallbackCallback) => void;
3
+ export default function promisify(fn: LegacyCallback): AgentCallbackPromise;
4
+ export {};
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function promisify(fn) {
4
+ return function (req, opts) {
5
+ return new Promise((resolve, reject) => {
6
+ fn.call(this, req, opts, (err, rtn) => {
7
+ if (err) {
8
+ reject(err);
9
+ }
10
+ else {
11
+ resolve(rtn);
12
+ }
13
+ });
14
+ });
15
+ };
16
+ }
17
+ exports.default = promisify;
18
+ //# sourceMappingURL=promisify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promisify.js","sourceRoot":"","sources":["../../src/promisify.ts"],"names":[],"mappings":";;AAeA,SAAwB,SAAS,CAAC,EAAkB;IACnD,OAAO,UAAsB,GAAkB,EAAE,IAAoB;QACpE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACtC,EAAE,CAAC,IAAI,CACN,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,CAAC,GAA6B,EAAE,GAAyB,EAAE,EAAE;gBAC5D,IAAI,GAAG,EAAE;oBACR,MAAM,CAAC,GAAG,CAAC,CAAC;iBACZ;qBAAM;oBACN,OAAO,CAAC,GAAG,CAAC,CAAC;iBACb;YACF,CAAC,CACD,CAAC;QACH,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;AACH,CAAC;AAjBD,4BAiBC"}