@mtcute/node 0.27.8 → 0.27.9
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/index.cjs +1 -0
- package/index.js +3 -2
- package/package.json +4 -4
- package/utils/proxies.cjs +6 -0
- package/utils/proxies.d.cts +12 -0
- package/utils/proxies.d.ts +12 -0
- package/utils/proxies.js +8 -2
package/index.cjs
CHANGED
|
@@ -23,6 +23,7 @@ exports.NodePlatform = platform.NodePlatform;
|
|
|
23
23
|
exports.HttpProxyTcpTransport = proxies.HttpProxyTcpTransport;
|
|
24
24
|
exports.MtProxyTcpTransport = proxies.MtProxyTcpTransport;
|
|
25
25
|
exports.SocksProxyTcpTransport = proxies.SocksProxyTcpTransport;
|
|
26
|
+
exports.proxyTransportFromUrl = proxies.proxyTransportFromUrl;
|
|
26
27
|
exports.TcpTransport = tcp.TcpTransport;
|
|
27
28
|
exports.TelegramWorker = worker.TelegramWorker;
|
|
28
29
|
exports.TelegramWorkerPort = worker.TelegramWorkerPort;
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseTelegramClient, TelegramClient } from "./client.js";
|
|
2
2
|
import { SqliteStorage } from "./sqlite/index.js";
|
|
3
3
|
import { NodePlatform } from "./utils/platform.js";
|
|
4
|
-
import { HttpProxyTcpTransport, MtProxyTcpTransport, SocksProxyTcpTransport } from "./utils/proxies.js";
|
|
4
|
+
import { HttpProxyTcpTransport, MtProxyTcpTransport, SocksProxyTcpTransport, proxyTransportFromUrl } from "./utils/proxies.js";
|
|
5
5
|
import { TcpTransport } from "./utils/tcp.js";
|
|
6
6
|
import { TelegramWorker, TelegramWorkerPort } from "./worker.js";
|
|
7
7
|
export * from "@mtcute/core";
|
|
@@ -22,5 +22,6 @@ export {
|
|
|
22
22
|
TcpTransport,
|
|
23
23
|
TelegramClient,
|
|
24
24
|
TelegramWorker,
|
|
25
|
-
TelegramWorkerPort
|
|
25
|
+
TelegramWorkerPort,
|
|
26
|
+
proxyTransportFromUrl
|
|
26
27
|
};
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mtcute/node",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.27.
|
|
4
|
+
"version": "0.27.9",
|
|
5
5
|
"description": "Meta-package for Node.js",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@mtcute/core": "^0.27.
|
|
9
|
-
"@mtcute/html-parser": "^0.27.
|
|
10
|
-
"@mtcute/markdown-parser": "^0.27.
|
|
8
|
+
"@mtcute/core": "^0.27.9",
|
|
9
|
+
"@mtcute/html-parser": "^0.27.9",
|
|
10
|
+
"@mtcute/markdown-parser": "^0.27.9",
|
|
11
11
|
"@mtcute/wasm": "^0.27.8",
|
|
12
12
|
"@fuman/utils": "0.0.19",
|
|
13
13
|
"@fuman/net": "0.0.19",
|
package/utils/proxies.cjs
CHANGED
|
@@ -60,6 +60,11 @@ class MtProxyTcpTransport extends core.BaseMtProxyTransport {
|
|
|
60
60
|
return node.connectTcp(endpoint);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
+
const proxyTransportFromUrl = core.createProxyTransportFactory({
|
|
64
|
+
SocksProxyTcpTransport,
|
|
65
|
+
HttpProxyTcpTransport,
|
|
66
|
+
MtProxyTcpTransport
|
|
67
|
+
});
|
|
63
68
|
Object.defineProperty(exports, "HttpProxyConnectionError", {
|
|
64
69
|
enumerable: true,
|
|
65
70
|
get: () => net.HttpProxyConnectionError
|
|
@@ -71,3 +76,4 @@ Object.defineProperty(exports, "SocksProxyConnectionError", {
|
|
|
71
76
|
exports.HttpProxyTcpTransport = HttpProxyTcpTransport;
|
|
72
77
|
exports.MtProxyTcpTransport = MtProxyTcpTransport;
|
|
73
78
|
exports.SocksProxyTcpTransport = SocksProxyTcpTransport;
|
|
79
|
+
exports.proxyTransportFromUrl = proxyTransportFromUrl;
|
package/utils/proxies.d.cts
CHANGED
|
@@ -32,3 +32,15 @@ export declare class SocksProxyTcpTransport implements TelegramTransport {
|
|
|
32
32
|
export declare class MtProxyTcpTransport extends BaseMtProxyTransport {
|
|
33
33
|
_connectTcp(endpoint: TcpEndpoint): Promise<ITcpConnection>;
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Create a proxy transport based on an url.
|
|
37
|
+
*
|
|
38
|
+
* Supported URLs (self-explanatory):
|
|
39
|
+
* - `socks4://user:pass@1.2.3.4:80`
|
|
40
|
+
* - `socks5://user:pass@1.2.3.4:80`
|
|
41
|
+
* - `http://user:pass@1.2.3.4:80`
|
|
42
|
+
* - `https://user:pass@1.2.3.4:443`
|
|
43
|
+
* - `https://t.me/proxy?server=example.com&port=443&secret=3dpBFlW2hP6Hq_WOwiNeKBY`
|
|
44
|
+
* @returns Transport for that proxy
|
|
45
|
+
*/
|
|
46
|
+
export declare const proxyTransportFromUrl: (url: string) => TelegramTransport;
|
package/utils/proxies.d.ts
CHANGED
|
@@ -32,3 +32,15 @@ export declare class SocksProxyTcpTransport implements TelegramTransport {
|
|
|
32
32
|
export declare class MtProxyTcpTransport extends BaseMtProxyTransport {
|
|
33
33
|
_connectTcp(endpoint: TcpEndpoint): Promise<ITcpConnection>;
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Create a proxy transport based on an url.
|
|
37
|
+
*
|
|
38
|
+
* Supported URLs (self-explanatory):
|
|
39
|
+
* - `socks4://user:pass@1.2.3.4:80`
|
|
40
|
+
* - `socks5://user:pass@1.2.3.4:80`
|
|
41
|
+
* - `http://user:pass@1.2.3.4:80`
|
|
42
|
+
* - `https://user:pass@1.2.3.4:443`
|
|
43
|
+
* - `https://t.me/proxy?server=example.com&port=443&secret=3dpBFlW2hP6Hq_WOwiNeKBY`
|
|
44
|
+
* @returns Transport for that proxy
|
|
45
|
+
*/
|
|
46
|
+
export declare const proxyTransportFromUrl: (url: string) => TelegramTransport;
|
package/utils/proxies.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { performHttpProxyHandshake, performSocksHandshake } from "@fuman/net";
|
|
2
2
|
import { HttpProxyConnectionError, SocksProxyConnectionError } from "@fuman/net";
|
|
3
3
|
import { connectTls, connectTcp } from "@fuman/node";
|
|
4
|
-
import { IntermediatePacketCodec, BaseMtProxyTransport } from "@mtcute/core";
|
|
4
|
+
import { createProxyTransportFactory, IntermediatePacketCodec, BaseMtProxyTransport } from "@mtcute/core";
|
|
5
5
|
class HttpProxyTcpTransport {
|
|
6
6
|
constructor(proxy) {
|
|
7
7
|
this.proxy = proxy;
|
|
@@ -54,10 +54,16 @@ class MtProxyTcpTransport extends BaseMtProxyTransport {
|
|
|
54
54
|
return connectTcp(endpoint);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
+
const proxyTransportFromUrl = createProxyTransportFactory({
|
|
58
|
+
SocksProxyTcpTransport,
|
|
59
|
+
HttpProxyTcpTransport,
|
|
60
|
+
MtProxyTcpTransport
|
|
61
|
+
});
|
|
57
62
|
export {
|
|
58
63
|
HttpProxyConnectionError,
|
|
59
64
|
HttpProxyTcpTransport,
|
|
60
65
|
MtProxyTcpTransport,
|
|
61
66
|
SocksProxyConnectionError,
|
|
62
|
-
SocksProxyTcpTransport
|
|
67
|
+
SocksProxyTcpTransport,
|
|
68
|
+
proxyTransportFromUrl
|
|
63
69
|
};
|