@openclaw/slack 2026.5.27 → 2026.5.28-beta.1
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/{account-inspect-vVg3pT03.js → account-inspect-CdGk6R7l.js} +1 -1
- package/dist/account-inspect-api.js +1 -1
- package/dist/{accounts-BnLQ3fe2.js → accounts-f6Xcv9Vi.js} +42 -1
- package/dist/accounts.runtime-BJt1IxOS.js +2 -0
- package/dist/{action-runtime-JVb7KyQs.js → action-runtime-BOEgcnv6.js} +7 -8
- package/dist/action-runtime.runtime-BXQYV0yA.js +2 -0
- package/dist/{actions-1o9nMIY8.js → actions-zfVWcIY6.js} +4 -4
- package/dist/{actions.runtime-qQtdNww-.js → actions.runtime-CoijPN8g.js} +1 -1
- package/dist/api.js +14 -17
- package/dist/{approval-handler.runtime-Ba8nwnYi.js → approval-handler.runtime-CWz3XLfN.js} +12 -69
- package/dist/{channel-Bd7eept6.js → channel-B9uavFQM.js} +25 -28
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.setup-WNNVmCm0.js → channel.setup-oGp4gSTP.js} +4 -4
- package/dist/{client-Dc2Ji2YN.js → client-DowBk5k0.js} +6 -24
- package/dist/{config-schema-CUiDK8HV.js → config-schema-C0RewpJQ.js} +4 -0
- package/dist/contract-api.js +1 -1
- package/dist/{directory-config-9_djLTOK.js → directory-config-8UPAEyNg.js} +1 -1
- package/dist/directory-contract-api.js +1 -1
- package/dist/{directory-live-Cl83cGLZ.js → directory-live-BFB1pSax.js} +2 -2
- package/dist/http-routes-api.js +1 -1
- package/dist/index.js +3 -7
- package/dist/{interactive-replies-DtYu4Sf5.js → interactive-replies-DrBq4Mld.js} +1 -1
- package/dist/interactive-replies-api.js +1 -1
- package/dist/{message-tool-api-BieXX5lk.js → message-tool-api-B9M0zzlQ.js} +2 -2
- package/dist/message-tool-api.js +1 -1
- package/dist/{monitor-Cn7LUDFL.js → monitor-BzzGqB63.js} +3 -4
- package/dist/{outbound-adapter-ChuR4_0v.js → outbound-adapter-BHZMgblN.js} +4 -7
- package/dist/{prepare-Bl5WcC3f.js → pipeline.runtime-XK36f1W3.js} +1769 -47
- package/dist/plugin-routes-B9PvcDQJ.js +22 -0
- package/dist/{policy-pu8tsF8_.js → policy-BBDU-PQK.js} +1 -1
- package/dist/{probe-cBVPhCKZ.js → probe-Djes9Fy6.js} +1 -1
- package/dist/{provider-Bccng2Wp.js → provider-CfZypaNV.js} +826 -26
- package/dist/{replies-jiEDV6lH.js → replies-DkmWK7JW.js} +2 -4
- package/dist/{resolve-channels-CT4oiz_9.js → resolve-channels-zXt5f47h.js} +1 -1
- package/dist/{resolve-users-o5S-Ijks.js → resolve-users-BLfGAz1v.js} +1 -1
- package/dist/{runtime-api-CyPE-EvY.js → runtime-api-DvpUD2hw.js} +2 -2
- package/dist/runtime-api.js +12 -12
- package/dist/{scopes-CnyhLIPT.js → scopes-DiiHsqh1.js} +1 -1
- package/dist/{send-DvfE8LVm.js → send-BURYyCXI.js} +4 -4
- package/dist/send.runtime-CKaMG3s-.js +2 -0
- package/dist/{setup-core-DKe7Ug3V.js → setup-core-POfI_bgP.js} +2 -2
- package/dist/setup-entry.js +8 -1
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-gjRthuZA.js → setup-surface-DJTHAguz.js} +5 -5
- package/dist/{shared-D8A7iVVH.js → shared-D9WMYymo.js} +5 -5
- package/dist/{slash-dispatch.runtime-BBhdJHb8.js → slash-dispatch.runtime-lsyTm_q5.js} +1 -1
- package/dist/thread-ts-NSVqWybn.js +646 -0
- package/node_modules/semver/classes/range.js +7 -0
- package/node_modules/semver/package.json +1 -1
- package/node_modules/semver/ranges/subset.js +2 -2
- package/npm-shrinkwrap.json +6 -29
- package/openclaw.plugin.json +10 -0
- package/package.json +8 -7
- package/dist/accounts.runtime-BVdtQeuq.js +0 -2
- package/dist/action-runtime.runtime-BZa5VDjs.js +0 -2
- package/dist/allow-list-B1lkGjwl.js +0 -82
- package/dist/blocks-render-CNC4vQnd.js +0 -232
- package/dist/inbound-contract-test-api.js +0 -3
- package/dist/magic-string.es-BPXBBMwL.js +0 -1011
- package/dist/outbound-payload-test-api.js +0 -2
- package/dist/outbound-payload.test-harness-8MnHFgR1.js +0 -13551
- package/dist/pipeline.runtime-BVK8yXw_.js +0 -1473
- package/dist/plugin-routes-DRR3ijKM.js +0 -20
- package/dist/prepare.test-helpers-BcAo4KMw.js +0 -49
- package/dist/reply-blocks-BlOURkUm.js +0 -290
- package/dist/room-context-BmNTBiw5.js +0 -816
- package/dist/send.runtime-Dv6ajTGK.js +0 -2
- package/dist/send.runtime-v3TSw9xY.js +0 -2
- package/dist/test-api.js +0 -8
- package/dist/thread-ts-ks-O8cEG.js +0 -52
- 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/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/dist/test-api.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { a as createSlackActions, t as slackPlugin } from "./channel-Bd7eept6.js";
|
|
2
|
-
import { n as setSlackRuntime } from "./runtime-BOk7xkOl.js";
|
|
3
|
-
import { t as sendMessageSlack } from "./send-DvfE8LVm.js";
|
|
4
|
-
import { t as prepareSlackMessage } from "./prepare-Bl5WcC3f.js";
|
|
5
|
-
import { t as createInboundSlackTestContext } from "./prepare.test-helpers-BcAo4KMw.js";
|
|
6
|
-
import { t as createSlackOutboundPayloadHarness } from "./outbound-payload.test-harness-8MnHFgR1.js";
|
|
7
|
-
import { n as slackOutbound } from "./outbound-adapter-ChuR4_0v.js";
|
|
8
|
-
export { createInboundSlackTestContext, createSlackActions, createSlackOutboundPayloadHarness, prepareSlackMessage, sendMessageSlack, setSlackRuntime, slackOutbound, slackPlugin };
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
2
|
-
//#region extensions/slack/src/truncate.ts
|
|
3
|
-
function truncateSlackText(value, max) {
|
|
4
|
-
const trimmed = value.trim();
|
|
5
|
-
if (trimmed.length <= max) return trimmed;
|
|
6
|
-
if (max <= 1) return trimmed.slice(0, max);
|
|
7
|
-
return `${trimmed.slice(0, max - 1)}…`;
|
|
8
|
-
}
|
|
9
|
-
//#endregion
|
|
10
|
-
//#region extensions/slack/src/limits.ts
|
|
11
|
-
const SLACK_TEXT_LIMIT = 8e3;
|
|
12
|
-
//#endregion
|
|
13
|
-
//#region extensions/slack/src/blocks-input.ts
|
|
14
|
-
const SLACK_MAX_BLOCKS = 50;
|
|
15
|
-
function parseBlocksJson(raw) {
|
|
16
|
-
try {
|
|
17
|
-
return JSON.parse(raw);
|
|
18
|
-
} catch {
|
|
19
|
-
throw new Error("blocks must be valid JSON");
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function assertBlocksArray(raw) {
|
|
23
|
-
if (!Array.isArray(raw)) throw new Error("blocks must be an array");
|
|
24
|
-
if (raw.length === 0) throw new Error("blocks must contain at least one block");
|
|
25
|
-
if (raw.length > 50) throw new Error(`blocks cannot exceed 50 items`);
|
|
26
|
-
for (const block of raw) {
|
|
27
|
-
if (!block || typeof block !== "object" || Array.isArray(block)) throw new Error("each block must be an object");
|
|
28
|
-
const type = block.type;
|
|
29
|
-
if (typeof type !== "string" || type.trim().length === 0) throw new Error("each block must include a non-empty string type");
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
function validateSlackBlocksArray(raw) {
|
|
33
|
-
assertBlocksArray(raw);
|
|
34
|
-
return raw;
|
|
35
|
-
}
|
|
36
|
-
function parseSlackBlocksInput(raw) {
|
|
37
|
-
if (raw == null) return;
|
|
38
|
-
return validateSlackBlocksArray(typeof raw === "string" ? parseBlocksJson(raw) : raw);
|
|
39
|
-
}
|
|
40
|
-
//#endregion
|
|
41
|
-
//#region extensions/slack/src/thread-ts.ts
|
|
42
|
-
const SLACK_THREAD_TS_PATTERN = /^\d+\.\d+$/;
|
|
43
|
-
function normalizeSlackThreadTsCandidate(value) {
|
|
44
|
-
if (typeof value !== "string") return;
|
|
45
|
-
const normalized = normalizeOptionalString(value);
|
|
46
|
-
return normalized && SLACK_THREAD_TS_PATTERN.test(normalized) ? normalized : void 0;
|
|
47
|
-
}
|
|
48
|
-
function resolveSlackThreadTsValue(params) {
|
|
49
|
-
return normalizeSlackThreadTsCandidate(params.replyToId) ?? normalizeSlackThreadTsCandidate(params.threadId);
|
|
50
|
-
}
|
|
51
|
-
//#endregion
|
|
52
|
-
export { validateSlackBlocksArray as a, parseSlackBlocksInput as i, resolveSlackThreadTsValue as n, SLACK_TEXT_LIMIT as o, SLACK_MAX_BLOCKS as r, truncateSlackText as s, normalizeSlackThreadTsCandidate as t };
|
|
@@ -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,69 +0,0 @@
|
|
|
1
|
-
agent-base
|
|
2
|
-
==========
|
|
3
|
-
### Turn a function into an [`http.Agent`][http.Agent] instance
|
|
4
|
-
|
|
5
|
-
This module is a thin wrapper around the base `http.Agent` class.
|
|
6
|
-
|
|
7
|
-
It provides an abstract class that must define a `connect()` function,
|
|
8
|
-
which is responsible for creating the underlying socket that the HTTP
|
|
9
|
-
client requests will use.
|
|
10
|
-
|
|
11
|
-
The `connect()` function may return an arbitrary `Duplex` stream, or
|
|
12
|
-
another `http.Agent` instance to delegate the request to, and may be
|
|
13
|
-
asynchronous (by defining an `async` function).
|
|
14
|
-
|
|
15
|
-
Instances of this agent can be used with the `http` and `https`
|
|
16
|
-
modules. To differentiate, the options parameter in the `connect()`
|
|
17
|
-
function includes a `secureEndpoint` property, which can be checked
|
|
18
|
-
to determine what type of socket should be returned.
|
|
19
|
-
|
|
20
|
-
#### Some subclasses:
|
|
21
|
-
|
|
22
|
-
Here are some more interesting uses of `agent-base`.
|
|
23
|
-
Send a pull request to list yours!
|
|
24
|
-
|
|
25
|
-
* [`http-proxy-agent`][http-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTP endpoints
|
|
26
|
-
* [`https-proxy-agent`][https-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTPS endpoints
|
|
27
|
-
* [`pac-proxy-agent`][pac-proxy-agent]: A PAC file proxy `http.Agent` implementation for HTTP and HTTPS
|
|
28
|
-
* [`socks-proxy-agent`][socks-proxy-agent]: A SOCKS proxy `http.Agent` implementation for HTTP and HTTPS
|
|
29
|
-
|
|
30
|
-
Example
|
|
31
|
-
-------
|
|
32
|
-
|
|
33
|
-
Here's a minimal example that creates a new `net.Socket` or `tls.Socket`
|
|
34
|
-
based on the `secureEndpoint` property. This agent can be used with both
|
|
35
|
-
the `http` and `https` modules.
|
|
36
|
-
|
|
37
|
-
```ts
|
|
38
|
-
import * as net from 'net';
|
|
39
|
-
import * as tls from 'tls';
|
|
40
|
-
import * as http from 'http';
|
|
41
|
-
import { Agent } from 'agent-base';
|
|
42
|
-
|
|
43
|
-
class MyAgent extends Agent {
|
|
44
|
-
connect(req, opts) {
|
|
45
|
-
// `secureEndpoint` is true when using the "https" module
|
|
46
|
-
if (opts.secureEndpoint) {
|
|
47
|
-
return tls.connect(opts);
|
|
48
|
-
} else {
|
|
49
|
-
return net.connect(opts);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
// Keep alive enabled means that `connect()` will only be
|
|
55
|
-
// invoked when a new connection needs to be created
|
|
56
|
-
const agent = new MyAgent({ keepAlive: true });
|
|
57
|
-
|
|
58
|
-
// Pass the `agent` option when creating the HTTP request
|
|
59
|
-
http.get('http://nodejs.org/api/', { agent }, (res) => {
|
|
60
|
-
console.log('"response" event!', res.headers);
|
|
61
|
-
res.pipe(process.stdout);
|
|
62
|
-
});
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
[http-proxy-agent]: ../http-proxy-agent
|
|
66
|
-
[https-proxy-agent]: ../https-proxy-agent
|
|
67
|
-
[pac-proxy-agent]: ../pac-proxy-agent
|
|
68
|
-
[socks-proxy-agent]: ../socks-proxy-agent
|
|
69
|
-
[http.Agent]: https://nodejs.org/api/http.html#http_class_http_agent
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as http from 'http';
|
|
2
|
-
import * as https from 'https';
|
|
3
|
-
import type { Readable } from 'stream';
|
|
4
|
-
export type ThenableRequest = http.ClientRequest & {
|
|
5
|
-
then: Promise<http.IncomingMessage>['then'];
|
|
6
|
-
};
|
|
7
|
-
export declare function toBuffer(stream: Readable): Promise<Buffer>;
|
|
8
|
-
export declare function json(stream: Readable): Promise<any>;
|
|
9
|
-
export declare function req(url: string | URL, opts?: https.RequestOptions): ThenableRequest;
|
|
10
|
-
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEvC,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,aAAa,GAAG;IAClD,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;CAC5C,CAAC;AAEF,wBAAsB,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAQhE;AAGD,wBAAsB,IAAI,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAUzD;AAED,wBAAgB,GAAG,CAClB,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,IAAI,GAAE,KAAK,CAAC,cAAmB,GAC7B,eAAe,CAcjB"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import * as http from 'http';
|
|
2
|
-
import * as https from 'https';
|
|
3
|
-
export async function toBuffer(stream) {
|
|
4
|
-
let length = 0;
|
|
5
|
-
const chunks = [];
|
|
6
|
-
for await (const chunk of stream) {
|
|
7
|
-
length += chunk.length;
|
|
8
|
-
chunks.push(chunk);
|
|
9
|
-
}
|
|
10
|
-
return Buffer.concat(chunks, length);
|
|
11
|
-
}
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
-
export async function json(stream) {
|
|
14
|
-
const buf = await toBuffer(stream);
|
|
15
|
-
const str = buf.toString('utf8');
|
|
16
|
-
try {
|
|
17
|
-
return JSON.parse(str);
|
|
18
|
-
}
|
|
19
|
-
catch (_err) {
|
|
20
|
-
const err = _err;
|
|
21
|
-
err.message += ` (input: ${str})`;
|
|
22
|
-
throw err;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
export function req(url, opts = {}) {
|
|
26
|
-
const href = typeof url === 'string' ? url : url.href;
|
|
27
|
-
const req = (href.startsWith('https:') ? https : http).request(url, opts);
|
|
28
|
-
const promise = new Promise((resolve, reject) => {
|
|
29
|
-
req
|
|
30
|
-
.once('response', resolve)
|
|
31
|
-
.once('error', reject)
|
|
32
|
-
.end();
|
|
33
|
-
});
|
|
34
|
-
req.then = promise.then.bind(promise);
|
|
35
|
-
return req;
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sour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C,OAAO,CAC7D,GAAG,EACH,IAAI,CACe,CAAC;IACrB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrE,GAAG;aACD,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC;aACzB,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC;aACrB,GAAG,EAAqB,CAAC;IAC5B,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACtC,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import * as net from 'net';
|
|
2
|
-
import * as tls from 'tls';
|
|
3
|
-
import * as http from 'http';
|
|
4
|
-
import type { Duplex } from 'stream';
|
|
5
|
-
export * from './helpers.js';
|
|
6
|
-
interface HttpConnectOpts extends net.TcpNetConnectOpts {
|
|
7
|
-
secureEndpoint: false;
|
|
8
|
-
protocol?: string;
|
|
9
|
-
}
|
|
10
|
-
interface HttpsConnectOpts extends tls.ConnectionOptions {
|
|
11
|
-
secureEndpoint: true;
|
|
12
|
-
protocol?: string;
|
|
13
|
-
port: number;
|
|
14
|
-
}
|
|
15
|
-
export type AgentConnectOpts = HttpConnectOpts | HttpsConnectOpts;
|
|
16
|
-
declare const INTERNAL: unique symbol;
|
|
17
|
-
export declare abstract class Agent extends http.Agent {
|
|
18
|
-
private [INTERNAL];
|
|
19
|
-
options: Partial<net.TcpNetConnectOpts & tls.ConnectionOptions>;
|
|
20
|
-
keepAlive: boolean;
|
|
21
|
-
constructor(opts?: http.AgentOptions);
|
|
22
|
-
abstract connect(req: http.ClientRequest, options: AgentConnectOpts): Promise<Duplex | http.Agent> | Duplex | http.Agent;
|
|
23
|
-
/**
|
|
24
|
-
* Determine whether this is an `http` or `https` request.
|
|
25
|
-
*/
|
|
26
|
-
isSecureEndpoint(options?: AgentConnectOpts): boolean;
|
|
27
|
-
private incrementSockets;
|
|
28
|
-
private decrementSockets;
|
|
29
|
-
getName(options?: AgentConnectOpts): string;
|
|
30
|
-
createSocket(req: http.ClientRequest, options: AgentConnectOpts, cb: (err: Error | null, s?: Duplex) => void): void;
|
|
31
|
-
createConnection(): Duplex;
|
|
32
|
-
get defaultPort(): number;
|
|
33
|
-
set defaultPort(v: number);
|
|
34
|
-
get protocol(): string;
|
|
35
|
-
set protocol(v: string);
|
|
36
|
-
}
|
|
37
|
-
//# 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;AAE7B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,cAAc,cAAc,CAAC;AAE7B,UAAU,eAAgB,SAAQ,GAAG,CAAC,iBAAiB;IACtD,cAAc,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,gBAAiB,SAAQ,GAAG,CAAC,iBAAiB;IACvD,cAAc,EAAE,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,MAAM,gBAAgB,GAAG,eAAe,GAAG,gBAAgB,CAAC;AAElE,QAAA,MAAM,QAAQ,eAAmC,CAAC;AAQlD,8BAAsB,KAAM,SAAQ,IAAI,CAAC,KAAK;IAC7C,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAgB;IAGlC,OAAO,EAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACjE,SAAS,EAAG,OAAO,CAAC;gBAER,IAAI,CAAC,EAAE,IAAI,CAAC,YAAY;IAKpC,QAAQ,CAAC,OAAO,CACf,GAAG,EAAE,IAAI,CAAC,aAAa,EACvB,OAAO,EAAE,gBAAgB,GACvB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,KAAK;IAErD;;OAEG;IACH,gBAAgB,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO;IAqCrD,OAAO,CAAC,gBAAgB;IAqBxB,OAAO,CAAC,gBAAgB;IAmBxB,OAAO,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,MAAM;IAQ3C,YAAY,CACX,GAAG,EAAE,IAAI,CAAC,aAAa,EACvB,OAAO,EAAE,gBAAgB,EACzB,EAAE,EAAE,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI;IAuC5C,gBAAgB,IAAI,MAAM;IAW1B,IAAI,WAAW,IAAI,MAAM,CAKxB;IAED,IAAI,WAAW,CAAC,CAAC,EAAE,MAAM,EAIxB;IAED,IAAI,QAAQ,IAAI,MAAM,CAKrB;IAED,IAAI,QAAQ,CAAC,CAAC,EAAE,MAAM,EAIrB;CACD"}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import * as net from 'net';
|
|
2
|
-
import * as http from 'http';
|
|
3
|
-
import { Agent as HttpsAgent } from 'https';
|
|
4
|
-
export * from './helpers.js';
|
|
5
|
-
const INTERNAL = Symbol('AgentBaseInternalState');
|
|
6
|
-
export class Agent extends http.Agent {
|
|
7
|
-
constructor(opts) {
|
|
8
|
-
super(opts);
|
|
9
|
-
this[INTERNAL] = {};
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Determine whether this is an `http` or `https` request.
|
|
13
|
-
*/
|
|
14
|
-
isSecureEndpoint(options) {
|
|
15
|
-
if (options) {
|
|
16
|
-
// First check the `secureEndpoint` property explicitly, since this
|
|
17
|
-
// means that a parent `Agent` is "passing through" to this instance.
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
-
if (typeof options.secureEndpoint === 'boolean') {
|
|
20
|
-
return options.secureEndpoint;
|
|
21
|
-
}
|
|
22
|
-
// If no explicit `secure` endpoint, check if `protocol` property is
|
|
23
|
-
// set. This will usually be the case since using a full string URL
|
|
24
|
-
// or `URL` instance should be the most common usage.
|
|
25
|
-
if (typeof options.protocol === 'string') {
|
|
26
|
-
return options.protocol === 'https:';
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
// Finally, if no `protocol` property was set, then fall back to
|
|
30
|
-
// checking the stack trace of the current call stack, and try to
|
|
31
|
-
// detect the "https" module.
|
|
32
|
-
const { stack } = new Error();
|
|
33
|
-
if (typeof stack !== 'string')
|
|
34
|
-
return false;
|
|
35
|
-
return stack
|
|
36
|
-
.split('\n')
|
|
37
|
-
.some((l) => l.indexOf('(https.js:') !== -1 ||
|
|
38
|
-
l.indexOf('node:https:') !== -1);
|
|
39
|
-
}
|
|
40
|
-
// In order to support async signatures in `connect()` and Node's native
|
|
41
|
-
// connection pooling in `http.Agent`, the array of sockets for each origin
|
|
42
|
-
// has to be updated synchronously. This is so the length of the array is
|
|
43
|
-
// accurate when `addRequest()` is next called. We achieve this by creating a
|
|
44
|
-
// fake socket and adding it to `sockets[origin]` and incrementing
|
|
45
|
-
// `totalSocketCount`.
|
|
46
|
-
incrementSockets(name) {
|
|
47
|
-
// If `maxSockets` and `maxTotalSockets` are both Infinity then there is no
|
|
48
|
-
// need to create a fake socket because Node.js native connection pooling
|
|
49
|
-
// will never be invoked.
|
|
50
|
-
if (this.maxSockets === Infinity && this.maxTotalSockets === Infinity) {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
// All instances of `sockets` are expected TypeScript errors. The
|
|
54
|
-
// alternative is to add it as a private property of this class but that
|
|
55
|
-
// will break TypeScript subclassing.
|
|
56
|
-
if (!this.sockets[name]) {
|
|
57
|
-
// @ts-expect-error `sockets` is readonly in `@types/node`
|
|
58
|
-
this.sockets[name] = [];
|
|
59
|
-
}
|
|
60
|
-
const fakeSocket = new net.Socket({ writable: false });
|
|
61
|
-
this.sockets[name].push(fakeSocket);
|
|
62
|
-
// @ts-expect-error `totalSocketCount` isn't defined in `@types/node`
|
|
63
|
-
this.totalSocketCount++;
|
|
64
|
-
return fakeSocket;
|
|
65
|
-
}
|
|
66
|
-
decrementSockets(name, socket) {
|
|
67
|
-
if (!this.sockets[name] || socket === null) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
const sockets = this.sockets[name];
|
|
71
|
-
const index = sockets.indexOf(socket);
|
|
72
|
-
if (index !== -1) {
|
|
73
|
-
sockets.splice(index, 1);
|
|
74
|
-
// @ts-expect-error `totalSocketCount` isn't defined in `@types/node`
|
|
75
|
-
this.totalSocketCount--;
|
|
76
|
-
if (sockets.length === 0) {
|
|
77
|
-
// @ts-expect-error `sockets` is readonly in `@types/node`
|
|
78
|
-
delete this.sockets[name];
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
// In order to properly update the socket pool, we need to call `getName()` on
|
|
83
|
-
// the core `https.Agent` if it is a secureEndpoint.
|
|
84
|
-
getName(options) {
|
|
85
|
-
const secureEndpoint = this.isSecureEndpoint(options);
|
|
86
|
-
if (secureEndpoint) {
|
|
87
|
-
return HttpsAgent.prototype.getName.call(this, options);
|
|
88
|
-
}
|
|
89
|
-
return super.getName(options);
|
|
90
|
-
}
|
|
91
|
-
createSocket(req, options, cb) {
|
|
92
|
-
const connectOpts = {
|
|
93
|
-
...options,
|
|
94
|
-
secureEndpoint: this.isSecureEndpoint(options),
|
|
95
|
-
};
|
|
96
|
-
const name = this.getName(connectOpts);
|
|
97
|
-
const fakeSocket = this.incrementSockets(name);
|
|
98
|
-
Promise.resolve()
|
|
99
|
-
.then(() => this.connect(req, connectOpts))
|
|
100
|
-
.then((socket) => {
|
|
101
|
-
this.decrementSockets(name, fakeSocket);
|
|
102
|
-
if (typeof socket
|
|
103
|
-
.addRequest === 'function') {
|
|
104
|
-
try {
|
|
105
|
-
return socket.addRequest(req, connectOpts);
|
|
106
|
-
}
|
|
107
|
-
catch (err) {
|
|
108
|
-
return cb(err);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
this[INTERNAL].currentSocket = socket;
|
|
112
|
-
// @ts-expect-error `createSocket()` isn't defined in `@types/node`
|
|
113
|
-
super.createSocket(req, options, cb);
|
|
114
|
-
}, (err) => {
|
|
115
|
-
this.decrementSockets(name, fakeSocket);
|
|
116
|
-
cb(err);
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
createConnection() {
|
|
120
|
-
const socket = this[INTERNAL].currentSocket;
|
|
121
|
-
this[INTERNAL].currentSocket = undefined;
|
|
122
|
-
if (!socket) {
|
|
123
|
-
throw new Error('No socket was returned in the `connect()` function');
|
|
124
|
-
}
|
|
125
|
-
return socket;
|
|
126
|
-
}
|
|
127
|
-
get defaultPort() {
|
|
128
|
-
return (this[INTERNAL].defaultPort ??
|
|
129
|
-
(this.protocol === 'https:' ? 443 : 80));
|
|
130
|
-
}
|
|
131
|
-
set defaultPort(v) {
|
|
132
|
-
if (this[INTERNAL]) {
|
|
133
|
-
this[INTERNAL].defaultPort = v;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
get protocol() {
|
|
137
|
-
return (this[INTERNAL].protocol ??
|
|
138
|
-
(this.isSecureEndpoint() ? 'https:' : 'http:'));
|
|
139
|
-
}
|
|
140
|
-
set protocol(v) {
|
|
141
|
-
if (this[INTERNAL]) {
|
|
142
|
-
this[INTERNAL].protocol = v;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
//# 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,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ACF,CAAC;CACD"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "agent-base",
|
|
3
|
-
"version": "9.0.0",
|
|
4
|
-
"type": "module",
|
|
5
|
-
"description": "Turn a function into an `http.Agent` instance",
|
|
6
|
-
"exports": {
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
8
|
-
"default": "./dist/index.js"
|
|
9
|
-
},
|
|
10
|
-
"files": [
|
|
11
|
-
"dist"
|
|
12
|
-
],
|
|
13
|
-
"repository": {
|
|
14
|
-
"type": "git",
|
|
15
|
-
"url": "https://github.com/TooTallNate/proxy-agents.git",
|
|
16
|
-
"directory": "packages/agent-base"
|
|
17
|
-
},
|
|
18
|
-
"keywords": [
|
|
19
|
-
"http",
|
|
20
|
-
"agent",
|
|
21
|
-
"base",
|
|
22
|
-
"barebones",
|
|
23
|
-
"https"
|
|
24
|
-
],
|
|
25
|
-
"author": "Nathan Rajlich <nathan@tootallnate.net> (http://n8.io/)",
|
|
26
|
-
"license": "MIT",
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"@types/debug": "^4.1.7",
|
|
29
|
-
"@types/node": "^22.13.0",
|
|
30
|
-
"@types/semver": "^7.3.13",
|
|
31
|
-
"@types/ws": "^8.5.4",
|
|
32
|
-
"async-listen": "^3.0.0",
|
|
33
|
-
"typescript": "^5.1.6",
|
|
34
|
-
"ws": "^8.13.0",
|
|
35
|
-
"tsconfig": "0.0.0"
|
|
36
|
-
},
|
|
37
|
-
"engines": {
|
|
38
|
-
"node": ">= 20"
|
|
39
|
-
},
|
|
40
|
-
"scripts": {
|
|
41
|
-
"build": "tsc",
|
|
42
|
-
"test": "vitest",
|
|
43
|
-
"lint": "eslint . --ext .ts",
|
|
44
|
-
"pack": "node ../../scripts/pack.mjs"
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -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,QAAQ,IAAI,MAAM,CAAC,EAAE,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE/E,KAAK,cAAc,GAAG;IACrB,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IACnD,KAAK,EAAE,IAAI,CAAC,GA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