@openclaw/discord 2026.5.27 → 2026.5.28-beta.2
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/dist/action-runtime-api.js +1 -1
- package/dist/{api-Kq7vtaSO.js → api-ChQJ1kfZ.js} +2 -5
- package/dist/api.js +14 -14
- package/dist/{approval-handler.runtime-BDxD97LJ.js → approval-handler.runtime-CIZiiFBd.js} +5 -18
- package/dist/{audit-BdUjE2tr.js → audit-D6BXQsYY.js} +3 -3
- package/dist/{channel-9YoMy5Jf.js → channel--B_psO5e.js} +16 -16
- package/dist/{channel-actions-DZfkB0nd.js → channel-actions-BOH34yJ5.js} +2 -2
- package/dist/{channel-actions.runtime-suaDJHH0.js → channel-actions.runtime-B1RCm1JP.js} +10 -13
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.setup-B-kHacpx.js → channel.setup-COYdCbY_.js} +3 -3
- package/dist/{components-Dlc81IU5.js → components-DX5Baphr.js} +61 -20
- package/dist/{config-schema-CTzLsQlB.js → config-schema-3tZYNVTM.js} +13 -1
- package/dist/contract-api.js +2 -2
- package/dist/{conversation-identity-DAEgiGDV.js → conversation-identity-Dugx5WfH.js} +2 -2
- package/dist/{directory-config-Cgp0csDd.js → directory-config-CcjUkNgK.js} +1 -1
- package/dist/directory-contract-api.js +1 -1
- package/dist/{directory-live-C-ECRrM8.js → directory-live-NOtxlJZ3.js} +2 -2
- package/dist/{doctor-Q80i7GdG.js → doctor-Dy7sI1sL.js} +1 -1
- package/dist/{handle-action.guild-admin-DWFTAcfd.js → handle-action.guild-admin-wC9VaAdl.js} +11 -8
- package/dist/index.js +1 -1
- package/dist/{manager.runtime-D6V2SPKr.js → manager.runtime-Bwgq6hJW.js} +4 -5
- package/dist/{message-handler-B5-UG_oD.js → message-handler-DhqxKFLP.js} +9 -9
- package/dist/{message-handler.preflight-Ddww-wnF.js → message-handler.preflight-BC8QmsWW.js} +10 -10
- package/dist/{message-handler.process-HWGh2NOP.js → message-handler.process-DE1an2G4.js} +85 -17
- package/dist/{message-utils-4w0_DPFE.js → message-utils-BlvuUPP4.js} +1 -1
- package/dist/{outbound-adapter-DYUYRaBd.js → outbound-adapter-BGrOFkR8.js} +9 -7
- package/dist/{pluralkit-BS1MuvYs.js → pluralkit-Cq_PUr06.js} +1 -1
- package/dist/{probe-DfIM7zSY.js → probe-CSBPZIYV.js} +1 -1
- package/dist/{probe.runtime-DoXDN3rt.js → probe.runtime-BhWW0223.js} +1 -1
- package/dist/{provider-CO6pih5z.js → provider-DIVQuJTw.js} +99 -44
- package/dist/{provider-session.runtime-BD5XLPI8.js → provider-session.runtime-C7jT_K-7.js} +3 -3
- package/dist/provider.runtime-BtnupyG-.js +2 -0
- package/dist/{resolve-allowlist-common-QzX-w4-_.js → resolve-allowlist-common-CzfIcLSO.js} +1 -1
- package/dist/{resolve-channels-pD06YNCU.js → resolve-channels-CQ13aBCV.js} +3 -3
- package/dist/{resolve-users-BiWLqNNO.js → resolve-users-Bj4Y4uWR.js} +3 -3
- package/dist/retry-after-CSukypPP.js +21 -0
- package/dist/{runtime-xSazIM0F.js → runtime-DA70ebm-.js} +26 -23
- package/dist/runtime-api.actions.js +2 -2
- package/dist/runtime-api.js +19 -19
- package/dist/runtime-api.lookup.js +5 -5
- package/dist/runtime-api.monitor-P-emTjcx.js +5 -0
- package/dist/runtime-api.monitor.js +4 -4
- package/dist/runtime-api.send.js +5 -5
- package/dist/runtime-api.threads.js +3 -3
- package/dist/{send-BzXZ8iUI.js → send-3r8QQkTY.js} +7 -7
- package/dist/{send.components-AK8K4TwB.js → send.components-2qRLUwBn.js} +6 -6
- package/dist/{send.outbound-ZrMnBa8C.js → send.outbound-LjX_KYiO.js} +3 -3
- package/dist/{send.receipt-BzfsP3Bb.js → send.receipt-Bo_43DQZ.js} +64 -35
- package/dist/{send.shared-ehnDGwXx.js → send.shared-CXctTF1I.js} +2 -2
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{shared-ToNRC7ax.js → shared-D3NkInmq.js} +2 -2
- package/dist/{subagent-hooks-Di_2iXU8.js → subagent-hooks-DoWTMQyQ.js} +2 -2
- package/dist/subagent-hooks-api.js +1 -1
- package/dist/{system-events-DbqKnNPF.js → system-events-DV85gUxb.js} +1 -1
- package/dist/{target-resolver-DXPvq5-L.js → target-resolver-DVpZI7ZL.js} +2 -2
- package/dist/targets-0WHF7kV0.js +3 -0
- package/dist/{thread-bindings-Bw40FTRZ.js → thread-bindings-Cm3GqlNC.js} +4 -4
- package/dist/{thread-bindings.discord-api-irWYI8YX.js → thread-bindings.discord-api-JrJXT7L0.js} +4 -4
- package/dist/{thread-bindings.manager-LoYZzlss.js → thread-bindings.manager-DqJuGG-r.js} +3 -3
- package/dist/transcripts-source-api.js +1 -1
- package/dist/{transcripts-source-CwahHAYt.js → transcripts-source-lEfSvSRD.js} +1 -1
- package/dist/{typing-Cv09OhaY.js → typing-DlT_14RX.js} +1 -1
- package/npm-shrinkwrap.json +3 -49
- package/openclaw.plugin.json +35 -1
- package/package.json +5 -7
- package/dist/inbound-context-B5EsqsSr.js +0 -48
- package/dist/provider.runtime-pUGk7VR5.js +0 -2
- package/dist/runtime-api.monitor-BjgSsR6H.js +0 -5
- package/dist/targets-BBVHRaeO.js +0 -3
- package/dist/test-api.js +0 -45
- package/node_modules/agent-base/LICENSE +0 -22
- package/node_modules/agent-base/README.md +0 -69
- package/node_modules/agent-base/dist/helpers.d.ts +0 -10
- package/node_modules/agent-base/dist/helpers.d.ts.map +0 -1
- package/node_modules/agent-base/dist/helpers.js +0 -37
- package/node_modules/agent-base/dist/helpers.js.map +0 -1
- package/node_modules/agent-base/dist/index.d.ts +0 -37
- package/node_modules/agent-base/dist/index.d.ts.map +0 -1
- package/node_modules/agent-base/dist/index.js +0 -146
- package/node_modules/agent-base/dist/index.js.map +0 -1
- package/node_modules/agent-base/package.json +0 -46
- package/node_modules/debug/LICENSE +0 -20
- package/node_modules/debug/README.md +0 -481
- package/node_modules/debug/package.json +0 -64
- package/node_modules/debug/src/browser.js +0 -272
- package/node_modules/debug/src/common.js +0 -292
- package/node_modules/debug/src/index.js +0 -10
- package/node_modules/debug/src/node.js +0 -263
- package/node_modules/https-proxy-agent/LICENSE +0 -22
- package/node_modules/https-proxy-agent/README.md +0 -70
- package/node_modules/https-proxy-agent/dist/index.d.ts +0 -43
- package/node_modules/https-proxy-agent/dist/index.d.ts.map +0 -1
- package/node_modules/https-proxy-agent/dist/index.js +0 -150
- package/node_modules/https-proxy-agent/dist/index.js.map +0 -1
- package/node_modules/https-proxy-agent/dist/parse-proxy-response.d.ts +0 -12
- package/node_modules/https-proxy-agent/dist/parse-proxy-response.d.ts.map +0 -1
- package/node_modules/https-proxy-agent/dist/parse-proxy-response.js +0 -94
- package/node_modules/https-proxy-agent/dist/parse-proxy-response.js.map +0 -1
- package/node_modules/https-proxy-agent/package.json +0 -50
- package/node_modules/ms/index.js +0 -162
- package/node_modules/ms/license.md +0 -21
- package/node_modules/ms/package.json +0 -38
- package/node_modules/ms/readme.md +0 -59
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Module dependencies.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const tty = require('tty');
|
|
6
|
-
const util = require('util');
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* This is the Node.js implementation of `debug()`.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
exports.init = init;
|
|
13
|
-
exports.log = log;
|
|
14
|
-
exports.formatArgs = formatArgs;
|
|
15
|
-
exports.save = save;
|
|
16
|
-
exports.load = load;
|
|
17
|
-
exports.useColors = useColors;
|
|
18
|
-
exports.destroy = util.deprecate(
|
|
19
|
-
() => {},
|
|
20
|
-
'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Colors.
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
exports.colors = [6, 2, 3, 4, 5, 1];
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
// Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
|
|
31
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
32
|
-
const supportsColor = require('supports-color');
|
|
33
|
-
|
|
34
|
-
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
|
35
|
-
exports.colors = [
|
|
36
|
-
20,
|
|
37
|
-
21,
|
|
38
|
-
26,
|
|
39
|
-
27,
|
|
40
|
-
32,
|
|
41
|
-
33,
|
|
42
|
-
38,
|
|
43
|
-
39,
|
|
44
|
-
40,
|
|
45
|
-
41,
|
|
46
|
-
42,
|
|
47
|
-
43,
|
|
48
|
-
44,
|
|
49
|
-
45,
|
|
50
|
-
56,
|
|
51
|
-
57,
|
|
52
|
-
62,
|
|
53
|
-
63,
|
|
54
|
-
68,
|
|
55
|
-
69,
|
|
56
|
-
74,
|
|
57
|
-
75,
|
|
58
|
-
76,
|
|
59
|
-
77,
|
|
60
|
-
78,
|
|
61
|
-
79,
|
|
62
|
-
80,
|
|
63
|
-
81,
|
|
64
|
-
92,
|
|
65
|
-
93,
|
|
66
|
-
98,
|
|
67
|
-
99,
|
|
68
|
-
112,
|
|
69
|
-
113,
|
|
70
|
-
128,
|
|
71
|
-
129,
|
|
72
|
-
134,
|
|
73
|
-
135,
|
|
74
|
-
148,
|
|
75
|
-
149,
|
|
76
|
-
160,
|
|
77
|
-
161,
|
|
78
|
-
162,
|
|
79
|
-
163,
|
|
80
|
-
164,
|
|
81
|
-
165,
|
|
82
|
-
166,
|
|
83
|
-
167,
|
|
84
|
-
168,
|
|
85
|
-
169,
|
|
86
|
-
170,
|
|
87
|
-
171,
|
|
88
|
-
172,
|
|
89
|
-
173,
|
|
90
|
-
178,
|
|
91
|
-
179,
|
|
92
|
-
184,
|
|
93
|
-
185,
|
|
94
|
-
196,
|
|
95
|
-
197,
|
|
96
|
-
198,
|
|
97
|
-
199,
|
|
98
|
-
200,
|
|
99
|
-
201,
|
|
100
|
-
202,
|
|
101
|
-
203,
|
|
102
|
-
204,
|
|
103
|
-
205,
|
|
104
|
-
206,
|
|
105
|
-
207,
|
|
106
|
-
208,
|
|
107
|
-
209,
|
|
108
|
-
214,
|
|
109
|
-
215,
|
|
110
|
-
220,
|
|
111
|
-
221
|
|
112
|
-
];
|
|
113
|
-
}
|
|
114
|
-
} catch (error) {
|
|
115
|
-
// Swallow - we only care if `supports-color` is available; it doesn't have to be.
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Build up the default `inspectOpts` object from the environment variables.
|
|
120
|
-
*
|
|
121
|
-
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
|
|
122
|
-
*/
|
|
123
|
-
|
|
124
|
-
exports.inspectOpts = Object.keys(process.env).filter(key => {
|
|
125
|
-
return /^debug_/i.test(key);
|
|
126
|
-
}).reduce((obj, key) => {
|
|
127
|
-
// Camel-case
|
|
128
|
-
const prop = key
|
|
129
|
-
.substring(6)
|
|
130
|
-
.toLowerCase()
|
|
131
|
-
.replace(/_([a-z])/g, (_, k) => {
|
|
132
|
-
return k.toUpperCase();
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
// Coerce string value into JS value
|
|
136
|
-
let val = process.env[key];
|
|
137
|
-
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
|
138
|
-
val = true;
|
|
139
|
-
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
|
140
|
-
val = false;
|
|
141
|
-
} else if (val === 'null') {
|
|
142
|
-
val = null;
|
|
143
|
-
} else {
|
|
144
|
-
val = Number(val);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
obj[prop] = val;
|
|
148
|
-
return obj;
|
|
149
|
-
}, {});
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Is stdout a TTY? Colored output is enabled when `true`.
|
|
153
|
-
*/
|
|
154
|
-
|
|
155
|
-
function useColors() {
|
|
156
|
-
return 'colors' in exports.inspectOpts ?
|
|
157
|
-
Boolean(exports.inspectOpts.colors) :
|
|
158
|
-
tty.isatty(process.stderr.fd);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Adds ANSI color escape codes if enabled.
|
|
163
|
-
*
|
|
164
|
-
* @api public
|
|
165
|
-
*/
|
|
166
|
-
|
|
167
|
-
function formatArgs(args) {
|
|
168
|
-
const {namespace: name, useColors} = this;
|
|
169
|
-
|
|
170
|
-
if (useColors) {
|
|
171
|
-
const c = this.color;
|
|
172
|
-
const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
|
|
173
|
-
const prefix = ` ${colorCode};1m${name} \u001B[0m`;
|
|
174
|
-
|
|
175
|
-
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
|
|
176
|
-
args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
|
|
177
|
-
} else {
|
|
178
|
-
args[0] = getDate() + name + ' ' + args[0];
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function getDate() {
|
|
183
|
-
if (exports.inspectOpts.hideDate) {
|
|
184
|
-
return '';
|
|
185
|
-
}
|
|
186
|
-
return new Date().toISOString() + ' ';
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
|
|
191
|
-
*/
|
|
192
|
-
|
|
193
|
-
function log(...args) {
|
|
194
|
-
return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Save `namespaces`.
|
|
199
|
-
*
|
|
200
|
-
* @param {String} namespaces
|
|
201
|
-
* @api private
|
|
202
|
-
*/
|
|
203
|
-
function save(namespaces) {
|
|
204
|
-
if (namespaces) {
|
|
205
|
-
process.env.DEBUG = namespaces;
|
|
206
|
-
} else {
|
|
207
|
-
// If you set a process.env field to null or undefined, it gets cast to the
|
|
208
|
-
// string 'null' or 'undefined'. Just delete instead.
|
|
209
|
-
delete process.env.DEBUG;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Load `namespaces`.
|
|
215
|
-
*
|
|
216
|
-
* @return {String} returns the previously persisted debug modes
|
|
217
|
-
* @api private
|
|
218
|
-
*/
|
|
219
|
-
|
|
220
|
-
function load() {
|
|
221
|
-
return process.env.DEBUG;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Init logic for `debug` instances.
|
|
226
|
-
*
|
|
227
|
-
* Create a new `inspectOpts` object in case `useColors` is set
|
|
228
|
-
* differently for a particular `debug` instance.
|
|
229
|
-
*/
|
|
230
|
-
|
|
231
|
-
function init(debug) {
|
|
232
|
-
debug.inspectOpts = {};
|
|
233
|
-
|
|
234
|
-
const keys = Object.keys(exports.inspectOpts);
|
|
235
|
-
for (let i = 0; i < keys.length; i++) {
|
|
236
|
-
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
module.exports = require('./common')(exports);
|
|
241
|
-
|
|
242
|
-
const {formatters} = module.exports;
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Map %o to `util.inspect()`, all on a single line.
|
|
246
|
-
*/
|
|
247
|
-
|
|
248
|
-
formatters.o = function (v) {
|
|
249
|
-
this.inspectOpts.colors = this.useColors;
|
|
250
|
-
return util.inspect(v, this.inspectOpts)
|
|
251
|
-
.split('\n')
|
|
252
|
-
.map(str => str.trim())
|
|
253
|
-
.join(' ');
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* Map %O to `util.inspect()`, allowing multiple lines if needed.
|
|
258
|
-
*/
|
|
259
|
-
|
|
260
|
-
formatters.O = function (v) {
|
|
261
|
-
this.inspectOpts.colors = this.useColors;
|
|
262
|
-
return util.inspect(v, this.inspectOpts);
|
|
263
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
(The MIT License)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
-
a copy of this software and associated documentation files (the
|
|
7
|
-
'Software'), to deal in the Software without restriction, including
|
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
-
the following conditions:
|
|
12
|
-
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
|
14
|
-
included in all copies or substantial portions of the Software.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
https-proxy-agent
|
|
2
|
-
================
|
|
3
|
-
### An HTTP(s) proxy `http.Agent` implementation for HTTPS
|
|
4
|
-
|
|
5
|
-
This module provides an `http.Agent` implementation that connects to a specified
|
|
6
|
-
HTTP or HTTPS proxy server, and can be used with the built-in `https` module.
|
|
7
|
-
|
|
8
|
-
Specifically, this `Agent` implementation connects to an intermediary "proxy"
|
|
9
|
-
server and issues the [CONNECT HTTP method][CONNECT], which tells the proxy to
|
|
10
|
-
open a direct TCP connection to the destination server.
|
|
11
|
-
|
|
12
|
-
Since this agent implements the CONNECT HTTP method, it also works with other
|
|
13
|
-
protocols that use this method when connecting over proxies (i.e. WebSockets).
|
|
14
|
-
See the "Examples" section below for more.
|
|
15
|
-
|
|
16
|
-
Examples
|
|
17
|
-
--------
|
|
18
|
-
|
|
19
|
-
#### `https` module example
|
|
20
|
-
|
|
21
|
-
```ts
|
|
22
|
-
import * as https from 'https';
|
|
23
|
-
import { HttpsProxyAgent } from 'https-proxy-agent';
|
|
24
|
-
|
|
25
|
-
const agent = new HttpsProxyAgent('http://168.63.76.32:3128');
|
|
26
|
-
|
|
27
|
-
https.get('https://example.com', { agent }, (res) => {
|
|
28
|
-
console.log('"response" event!', res.headers);
|
|
29
|
-
res.pipe(process.stdout);
|
|
30
|
-
});
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
#### `ws` WebSocket connection example
|
|
34
|
-
|
|
35
|
-
```ts
|
|
36
|
-
import WebSocket from 'ws';
|
|
37
|
-
import { HttpsProxyAgent } from 'https-proxy-agent';
|
|
38
|
-
|
|
39
|
-
const agent = new HttpsProxyAgent('http://168.63.76.32:3128');
|
|
40
|
-
const socket = new WebSocket('ws://echo.websocket.org', { agent });
|
|
41
|
-
|
|
42
|
-
socket.on('open', function () {
|
|
43
|
-
console.log('"open" event!');
|
|
44
|
-
socket.send('hello world');
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
socket.on('message', function (data, flags) {
|
|
48
|
-
console.log('"message" event! %j %j', data, flags);
|
|
49
|
-
socket.close();
|
|
50
|
-
});
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
API
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
### new HttpsProxyAgent(proxy: string | URL, options?: HttpsProxyAgentOptions)
|
|
57
|
-
|
|
58
|
-
The `HttpsProxyAgent` class implements an `http.Agent` subclass that connects
|
|
59
|
-
to the specified "HTTP(s) proxy server" in order to proxy HTTPS and/or WebSocket
|
|
60
|
-
requests. This is achieved by using the [HTTP `CONNECT` method][CONNECT].
|
|
61
|
-
|
|
62
|
-
The `proxy` argument is the URL for the proxy server.
|
|
63
|
-
|
|
64
|
-
The `options` argument accepts the usual `http.Agent` constructor options, and
|
|
65
|
-
some additional properties:
|
|
66
|
-
|
|
67
|
-
* `headers` - Object containing additional headers to send to the proxy server
|
|
68
|
-
in the `CONNECT` request.
|
|
69
|
-
|
|
70
|
-
[CONNECT]: http://en.wikipedia.org/wiki/HTTP_tunnel#HTTP_CONNECT_Tunneling
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import * as net from 'net';
|
|
2
|
-
import * as tls from 'tls';
|
|
3
|
-
import * as http from 'http';
|
|
4
|
-
import { Agent, AgentConnectOpts } from 'agent-base';
|
|
5
|
-
import { URL } from 'url';
|
|
6
|
-
import type { OutgoingHttpHeaders } from 'http';
|
|
7
|
-
type Protocol<T> = T extends `${infer Protocol}:${infer _}` ? Protocol : never;
|
|
8
|
-
type ConnectOptsMap = {
|
|
9
|
-
http: Omit<net.TcpNetConnectOpts, 'host' | 'port'>;
|
|
10
|
-
https: Omit<tls.ConnectionOptions, 'host' | 'port'>;
|
|
11
|
-
};
|
|
12
|
-
type ConnectOpts<T> = {
|
|
13
|
-
[P in keyof ConnectOptsMap]: Protocol<T> extends P ? ConnectOptsMap[P] : never;
|
|
14
|
-
}[keyof ConnectOptsMap];
|
|
15
|
-
export type HttpsProxyAgentOptions<T> = ConnectOpts<T> & http.AgentOptions & {
|
|
16
|
-
headers?: OutgoingHttpHeaders | (() => OutgoingHttpHeaders);
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* The `HttpsProxyAgent` implements an HTTP Agent subclass that connects to
|
|
20
|
-
* the specified "HTTP(s) proxy server" in order to proxy HTTPS requests.
|
|
21
|
-
*
|
|
22
|
-
* Outgoing HTTP requests are first tunneled through the proxy server using the
|
|
23
|
-
* `CONNECT` HTTP request method to establish a connection to the proxy server,
|
|
24
|
-
* and then the proxy server connects to the destination target and issues the
|
|
25
|
-
* HTTP request from the proxy server.
|
|
26
|
-
*
|
|
27
|
-
* `https:` requests have their socket connection upgraded to TLS once
|
|
28
|
-
* the connection to the proxy server has been established.
|
|
29
|
-
*/
|
|
30
|
-
export declare class HttpsProxyAgent<Uri extends string> extends Agent {
|
|
31
|
-
static protocols: readonly ["http", "https"];
|
|
32
|
-
readonly proxy: URL;
|
|
33
|
-
proxyHeaders: OutgoingHttpHeaders | (() => OutgoingHttpHeaders);
|
|
34
|
-
connectOpts: net.TcpNetConnectOpts & tls.ConnectionOptions;
|
|
35
|
-
constructor(proxy: Uri | URL, opts?: HttpsProxyAgentOptions<Uri>);
|
|
36
|
-
/**
|
|
37
|
-
* Called when the node-core HTTP client library is creating a
|
|
38
|
-
* new HTTP request.
|
|
39
|
-
*/
|
|
40
|
-
connect(req: http.ClientRequest, opts: AgentConnectOpts): Promise<net.Socket>;
|
|
41
|
-
}
|
|
42
|
-
export {};
|
|
43
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAG7B,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAuBhD,KAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,MAAM,Q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|
-
import * as tls from 'tls';
|
|
3
|
-
import assert from 'assert';
|
|
4
|
-
import createDebug from 'debug';
|
|
5
|
-
import { Agent } from 'agent-base';
|
|
6
|
-
import { URL } from 'url';
|
|
7
|
-
import { parseProxyResponse } from './parse-proxy-response.js';
|
|
8
|
-
const debug = createDebug('https-proxy-agent');
|
|
9
|
-
const setServernameFromNonIpHost = (options) => {
|
|
10
|
-
if (options.servername === undefined &&
|
|
11
|
-
options.host &&
|
|
12
|
-
!net.isIP(options.host)) {
|
|
13
|
-
return {
|
|
14
|
-
...options,
|
|
15
|
-
servername: options.host,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
return options;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* The `HttpsProxyAgent` implements an HTTP Agent subclass that connects to
|
|
22
|
-
* the specified "HTTP(s) proxy server" in order to proxy HTTPS requests.
|
|
23
|
-
*
|
|
24
|
-
* Outgoing HTTP requests are first tunneled through the proxy server using the
|
|
25
|
-
* `CONNECT` HTTP request method to establish a connection to the proxy server,
|
|
26
|
-
* and then the proxy server connects to the destination target and issues the
|
|
27
|
-
* HTTP request from the proxy server.
|
|
28
|
-
*
|
|
29
|
-
* `https:` requests have their socket connection upgraded to TLS once
|
|
30
|
-
* the connection to the proxy server has been established.
|
|
31
|
-
*/
|
|
32
|
-
export class HttpsProxyAgent extends Agent {
|
|
33
|
-
constructor(proxy, opts) {
|
|
34
|
-
super(opts);
|
|
35
|
-
this.options = { path: undefined };
|
|
36
|
-
this.proxy = typeof proxy === 'string' ? new URL(proxy) : proxy;
|
|
37
|
-
this.proxyHeaders = opts?.headers ?? {};
|
|
38
|
-
debug('Creating new HttpsProxyAgent instance: %o', this.proxy.href);
|
|
39
|
-
// Trim off the brackets from IPv6 addresses
|
|
40
|
-
const host = (this.proxy.hostname || this.proxy.host).replace(/^\[|\]$/g, '');
|
|
41
|
-
const port = this.proxy.port
|
|
42
|
-
? parseInt(this.proxy.port, 10)
|
|
43
|
-
: this.proxy.protocol === 'https:'
|
|
44
|
-
? 443
|
|
45
|
-
: 80;
|
|
46
|
-
this.connectOpts = {
|
|
47
|
-
// Attempt to negotiate http/1.1 for proxy servers that support http/2
|
|
48
|
-
ALPNProtocols: ['http/1.1'],
|
|
49
|
-
...(opts ? omit(opts, 'headers') : null),
|
|
50
|
-
host,
|
|
51
|
-
port,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Called when the node-core HTTP client library is creating a
|
|
56
|
-
* new HTTP request.
|
|
57
|
-
*/
|
|
58
|
-
async connect(req, opts) {
|
|
59
|
-
const { proxy } = this;
|
|
60
|
-
if (!opts.host) {
|
|
61
|
-
throw new TypeError('No "host" provided');
|
|
62
|
-
}
|
|
63
|
-
// Create a socket connection to the proxy server.
|
|
64
|
-
let socket;
|
|
65
|
-
if (proxy.protocol === 'https:') {
|
|
66
|
-
debug('Creating `tls.Socket`: %o', this.connectOpts);
|
|
67
|
-
socket = tls.connect(setServernameFromNonIpHost(this.connectOpts));
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
debug('Creating `net.Socket`: %o', this.connectOpts);
|
|
71
|
-
socket = net.connect(this.connectOpts);
|
|
72
|
-
}
|
|
73
|
-
const headers = typeof this.proxyHeaders === 'function'
|
|
74
|
-
? this.proxyHeaders()
|
|
75
|
-
: { ...this.proxyHeaders };
|
|
76
|
-
const host = net.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
|
|
77
|
-
let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r\n`;
|
|
78
|
-
// Inject the `Proxy-Authorization` header if necessary.
|
|
79
|
-
if (proxy.username || proxy.password) {
|
|
80
|
-
const auth = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`;
|
|
81
|
-
headers['Proxy-Authorization'] = `Basic ${Buffer.from(auth).toString('base64')}`;
|
|
82
|
-
}
|
|
83
|
-
headers.Host = `${host}:${opts.port}`;
|
|
84
|
-
if (!headers['Proxy-Connection']) {
|
|
85
|
-
headers['Proxy-Connection'] = this.keepAlive
|
|
86
|
-
? 'Keep-Alive'
|
|
87
|
-
: 'close';
|
|
88
|
-
}
|
|
89
|
-
for (const name of Object.keys(headers)) {
|
|
90
|
-
payload += `${name}: ${headers[name]}\r\n`;
|
|
91
|
-
}
|
|
92
|
-
const proxyResponsePromise = parseProxyResponse(socket);
|
|
93
|
-
socket.write(`${payload}\r\n`);
|
|
94
|
-
const { connect, buffered } = await proxyResponsePromise;
|
|
95
|
-
req.emit('proxyConnect', connect);
|
|
96
|
-
this.emit('proxyConnect', connect, req);
|
|
97
|
-
if (connect.statusCode === 200) {
|
|
98
|
-
req.once('socket', resume);
|
|
99
|
-
if (opts.secureEndpoint) {
|
|
100
|
-
// The proxy is connecting to a TLS server, so upgrade
|
|
101
|
-
// this socket connection to a TLS connection.
|
|
102
|
-
debug('Upgrading socket connection to TLS');
|
|
103
|
-
return tls.connect({
|
|
104
|
-
...omit(setServernameFromNonIpHost(opts), 'host', 'path', 'port'),
|
|
105
|
-
socket,
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
return socket;
|
|
109
|
-
}
|
|
110
|
-
// Some other status code that's not 200... need to re-play the HTTP
|
|
111
|
-
// header "data" events onto the socket once the HTTP machinery is
|
|
112
|
-
// attached so that the node core `http` can parse and handle the
|
|
113
|
-
// error status code.
|
|
114
|
-
// Close the original socket, and a new "fake" socket is returned
|
|
115
|
-
// instead, so that the proxy doesn't get the HTTP request
|
|
116
|
-
// written to it (which may contain `Authorization` headers or other
|
|
117
|
-
// sensitive data).
|
|
118
|
-
//
|
|
119
|
-
// See: https://hackerone.com/reports/541502
|
|
120
|
-
socket.destroy();
|
|
121
|
-
const fakeSocket = new net.Socket({ writable: false });
|
|
122
|
-
fakeSocket.readable = true;
|
|
123
|
-
// Need to wait for the "socket" event to re-play the "data" events.
|
|
124
|
-
req.once('socket', (s) => {
|
|
125
|
-
debug('Replaying proxy buffer for failed request');
|
|
126
|
-
assert(s.listenerCount('data') > 0);
|
|
127
|
-
// Replay the "buffered" Buffer onto the fake `socket`, since at
|
|
128
|
-
// this point the HTTP module machinery has been hooked up for
|
|
129
|
-
// the user.
|
|
130
|
-
s.push(buffered);
|
|
131
|
-
s.push(null);
|
|
132
|
-
});
|
|
133
|
-
return fakeSocket;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
HttpsProxyAgent.protocols = ['http', 'https'];
|
|
137
|
-
function resume(socket) {
|
|
138
|
-
socket.resume();
|
|
139
|
-
}
|
|
140
|
-
function omit(obj, ...keys) {
|
|
141
|
-
const ret = {};
|
|
142
|
-
let key;
|
|
143
|
-
for (key in obj) {
|
|
144
|
-
if (!keys.includes(key)) {
|
|
145
|
-
ret[key] = obj[key];
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return ret;
|
|
149
|
-
}
|
|
150
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAE3B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,WAAW,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,KAAK,EAAoB,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAG/D,MAAM,KAAK,GAAG,WAAW,CAAC,mBAAmB,CAAC,CAAC;AAE/C,MAAM,0BAA0B,GAAG,CAGlC,OAAU,EACT,EAAE;IACH,IACC,OAAO,CAAC,UAAU,KAAK,SAAS;QAChC,OAAO,CAAC,IAAI;QACZ,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EACtB,CAAC;QACF,OAAO;YACN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,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;IACF,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { IncomingHttpHeaders } from 'http';
|
|
2
|
-
import { Readable } from 'stream';
|
|
3
|
-
export interface ConnectResponse {
|
|
4
|
-
statusCode: number;
|
|
5
|
-
statusText: string;
|
|
6
|
-
headers: IncomingHttpHeaders;
|
|
7
|
-
}
|
|
8
|
-
export declare function parseProxyResponse(socket: Readable): Promise<{
|
|
9
|
-
connect: ConnectResponse;
|
|
10
|
-
buffered: Buffer;
|
|
11
|
-
}>;
|
|
12
|
-
//# sourceMappingURL=parse-proxy-response.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-proxy-response.d.ts","sourceRoot":"","sources":["../src/parse-proxy-response.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAIlC,MAAM,WAAW,eAAe;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,mBAAmB,CAAC;CAC7B;AAED,wBAAgB,kBAAkB,CACjC,MAAM,EAAE,QAAQ,GACd,OAAO,CAAC;IAAE,OAAO,EAAE,eAAe,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAyGzD"}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import createDebug from 'debug';
|
|
2
|
-
const debug = createDebug('https-proxy-agent:parse-proxy-response');
|
|
3
|
-
export function parseProxyResponse(socket) {
|
|
4
|
-
return new Promise((resolve, reject) => {
|
|
5
|
-
// we need to buffer any HTTP traffic that happens with the proxy before we get
|
|
6
|
-
// the CONNECT response, so that if the response is anything other than an "200"
|
|
7
|
-
// response code, then we can re-play the "data" events on the socket once the
|
|
8
|
-
// HTTP parser is hooked up...
|
|
9
|
-
let buffersLength = 0;
|
|
10
|
-
const buffers = [];
|
|
11
|
-
function read() {
|
|
12
|
-
const b = socket.read();
|
|
13
|
-
if (b)
|
|
14
|
-
ondata(b);
|
|
15
|
-
else
|
|
16
|
-
socket.once('readable', read);
|
|
17
|
-
}
|
|
18
|
-
function cleanup() {
|
|
19
|
-
socket.removeListener('end', onend);
|
|
20
|
-
socket.removeListener('error', onerror);
|
|
21
|
-
socket.removeListener('readable', read);
|
|
22
|
-
}
|
|
23
|
-
function onend() {
|
|
24
|
-
cleanup();
|
|
25
|
-
debug('onend');
|
|
26
|
-
reject(new Error('Proxy connection ended before receiving CONNECT response'));
|
|
27
|
-
}
|
|
28
|
-
function onerror(err) {
|
|
29
|
-
cleanup();
|
|
30
|
-
debug('onerror %o', err);
|
|
31
|
-
reject(err);
|
|
32
|
-
}
|
|
33
|
-
function ondata(b) {
|
|
34
|
-
buffers.push(b);
|
|
35
|
-
buffersLength += b.length;
|
|
36
|
-
const buffered = Buffer.concat(buffers, buffersLength);
|
|
37
|
-
const endOfHeaders = buffered.indexOf('\r\n\r\n');
|
|
38
|
-
if (endOfHeaders === -1) {
|
|
39
|
-
// keep buffering
|
|
40
|
-
debug('have not received end of HTTP headers yet...');
|
|
41
|
-
read();
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const headerParts = buffered
|
|
45
|
-
.slice(0, endOfHeaders)
|
|
46
|
-
.toString('ascii')
|
|
47
|
-
.split('\r\n');
|
|
48
|
-
const firstLine = headerParts.shift();
|
|
49
|
-
if (!firstLine) {
|
|
50
|
-
socket.destroy();
|
|
51
|
-
return reject(new Error('No header received from proxy CONNECT response'));
|
|
52
|
-
}
|
|
53
|
-
const firstLineParts = firstLine.split(' ');
|
|
54
|
-
const statusCode = +firstLineParts[1];
|
|
55
|
-
const statusText = firstLineParts.slice(2).join(' ');
|
|
56
|
-
const headers = {};
|
|
57
|
-
for (const header of headerParts) {
|
|
58
|
-
if (!header)
|
|
59
|
-
continue;
|
|
60
|
-
const firstColon = header.indexOf(':');
|
|
61
|
-
if (firstColon === -1) {
|
|
62
|
-
socket.destroy();
|
|
63
|
-
return reject(new Error(`Invalid header from proxy CONNECT response: "${header}"`));
|
|
64
|
-
}
|
|
65
|
-
const key = header.slice(0, firstColon).toLowerCase();
|
|
66
|
-
const value = header.slice(firstColon + 1).trimStart();
|
|
67
|
-
const current = headers[key];
|
|
68
|
-
if (typeof current === 'string') {
|
|
69
|
-
headers[key] = [current, value];
|
|
70
|
-
}
|
|
71
|
-
else if (Array.isArray(current)) {
|
|
72
|
-
current.push(value);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
headers[key] = value;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
debug('got proxy server response: %o %o', firstLine, headers);
|
|
79
|
-
cleanup();
|
|
80
|
-
resolve({
|
|
81
|
-
connect: {
|
|
82
|
-
statusCode,
|
|
83
|
-
statusText,
|
|
84
|
-
headers,
|
|
85
|
-
},
|
|
86
|
-
buffered,
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
socket.on('error', onerror);
|
|
90
|
-
socket.on('end', onend);
|
|
91
|
-
read();
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
//# sourceMappingURL=parse-proxy-response.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-proxy-response.js","sourceRoot":"","sources":["../src/parse-proxy-response.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,OAAO,CAAC;AAIhC,MAAM,KAAK,GAAG,WAAW,CAAC,wCAAwC,CAAC,CAAC;AAQpE,MAAM,UAAU,kBAAkB,CACjC,MAAgB;IAEhB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,+EAA+E;QAC/E,gFAAgF;QAChF,8EAA8E;QAC9E,8BAA8B;QAC9B,IAAI,aAAa,GAAG,CAAC,CAAC;QACtB,M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