xshell 1.2.45 → 1.2.47
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/net.d.ts +4 -5
- package/net.js +17 -19
- package/package.json +15 -15
- package/tsconfig.json +4 -0
package/net.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type Readable } from 'stream';
|
|
2
|
-
import type { FormData } from 'undici';
|
|
3
2
|
import type { WebSocket, CloseEvent, ErrorEvent } from 'ws';
|
|
4
3
|
import type { Cookie, CookieJar, MemoryCookieStore } from 'tough-cookie';
|
|
5
4
|
import { type Message } from './io.ts';
|
|
@@ -45,7 +44,7 @@ export interface RequestOptions {
|
|
|
45
44
|
method?: 'GET' | 'POST' | 'PUT' | 'HEAD' | 'DELETE' | 'PATCH';
|
|
46
45
|
queries?: Record<string, any>;
|
|
47
46
|
headers?: Record<string, string>;
|
|
48
|
-
body?: string | Record<string, any> | Uint8Array | URLSearchParams |
|
|
47
|
+
body?: string | Record<string, any> | Uint8Array | URLSearchParams | Readable;
|
|
49
48
|
type?: 'application/json' | 'application/x-www-form-urlencoded' | 'multipart/form-data';
|
|
50
49
|
proxy?: boolean | MyProxy | string;
|
|
51
50
|
encoding?: Encoding | 'binary';
|
|
@@ -90,7 +89,7 @@ export declare class StatusCodeError extends Error {
|
|
|
90
89
|
- Uint8Array
|
|
91
90
|
- Record<string, any>: 会自动 JSON.stringify
|
|
92
91
|
- URLSearchParams: 仅限 type 为 x-www-form-urlencoded
|
|
93
|
-
- FormData: 仅限 type 为 form-data
|
|
92
|
+
- Record<string, string | Blob | File> 自动转为 FormData: 仅限 type 为 form-data, 可以传 File 对象设置文件名
|
|
94
93
|
- type?: `'application/json'` 有 body 时设置 http 请求头中的 content-type 头
|
|
95
94
|
- proxy?: `false` 通过代理发送请求
|
|
96
95
|
- 为 true 时使用 MyProxy.socks5
|
|
@@ -104,7 +103,7 @@ export declare class StatusCodeError extends Error {
|
|
|
104
103
|
- cookies?: 需要额外添加到请求的 cookies, 默认情况下携带了 MemoryCookieStore 中保存的之前 http 响应中的 cookies
|
|
105
104
|
- raw?: `false` 传入后返回整个 response (RawResponse),body 为 Readable
|
|
106
105
|
- full?: `false` 传入后返回整个 response (FullResponse),body 根据 encoding 对应为 string 或 Buffer
|
|
107
|
-
- decode?: 根据 content-encoding: br 等解码压缩后的 response.body
|
|
106
|
+
- decode?: `true` 根据 content-encoding: br 等解码压缩后的 response.body
|
|
108
107
|
- print?:
|
|
109
108
|
- retry: `true` 是否打印 "等待 1 秒后重试 request" 提示信息
|
|
110
109
|
- timeout: `true` 是否打印最后一次超时重试失败时的错误 */
|
|
@@ -298,5 +297,5 @@ export declare class RemoteClient {
|
|
|
298
297
|
[inspect.custom](): {
|
|
299
298
|
remote: string;
|
|
300
299
|
websocket: string;
|
|
301
|
-
} & Omit<this,
|
|
300
|
+
} & Omit<this, typeof import("util").inspect.custom | "websocket" | "remote" | "call" | "send">;
|
|
302
301
|
}
|
package/net.js
CHANGED
|
@@ -41,8 +41,7 @@ const drop_request_headers = new Set([
|
|
|
41
41
|
]);
|
|
42
42
|
let agents = {};
|
|
43
43
|
async function request_retry(url, options, _timeout, retries = 0, count = 0, print) {
|
|
44
|
-
|
|
45
|
-
undici_request ??= undici.request;
|
|
44
|
+
const { default: undici } = await import('undici');
|
|
46
45
|
try {
|
|
47
46
|
if (_timeout > 0) {
|
|
48
47
|
// 设置给 undici 设置 timeout, signal 不一定管用,还是得自己兜底
|
|
@@ -81,9 +80,9 @@ export class StatusCodeError extends Error {
|
|
|
81
80
|
}
|
|
82
81
|
}
|
|
83
82
|
export async function request(url, options = {}) {
|
|
84
|
-
let { default: undici, ProxyAgent: UndiciProxyAgent, FormData } = await import('undici');
|
|
83
|
+
let { default: undici, ProxyAgent: UndiciProxyAgent, FormData: UndiciFormData } = await import('undici');
|
|
85
84
|
UndiciProxyAgent ??= undici.ProxyAgent;
|
|
86
|
-
|
|
85
|
+
UndiciFormData ??= undici.FormData;
|
|
87
86
|
const { Cookie } = await import('tough-cookie');
|
|
88
87
|
await cookies.init();
|
|
89
88
|
const { queries, headers: _headers, body, type = 'application/json', timeout = 5 * 1000, auth, cookies: _cookies, raw = false, full = false, redirect = 'follow', decode = true, print = {
|
|
@@ -108,11 +107,15 @@ export async function request(url, options = {}) {
|
|
|
108
107
|
let headers = {
|
|
109
108
|
'accept-language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,ja-JP;q=0.6,ja;q=0.5',
|
|
110
109
|
'accept-encoding': 'gzip, deflate, br',
|
|
111
|
-
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/
|
|
110
|
+
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36',
|
|
112
111
|
'sec-ch-ua-platform': '"Windows"',
|
|
113
|
-
'sec-ch-ua-platform-version': '"
|
|
112
|
+
'sec-ch-ua-platform-version': '"19.0.0"',
|
|
114
113
|
};
|
|
115
|
-
|
|
114
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest_API/Using_FormData_Objects
|
|
115
|
+
// When using FormData to submit POST requests using XMLHttpRequest or the Fetch API with the multipart/form-data content type (e.g., when uploading files and blobs to the server),
|
|
116
|
+
// do not explicitly set the Content-Type header on the request.
|
|
117
|
+
// Doing so will prevent the browser from being able to set the Content-Type header with the boundary expression it will use to delimit form fields in the request body.
|
|
118
|
+
if (body !== undefined && type !== 'multipart/form-data')
|
|
116
119
|
headers['content-type'] = type;
|
|
117
120
|
if (auth)
|
|
118
121
|
headers.authorization = auth.type === 'basic' ?
|
|
@@ -178,19 +181,14 @@ export async function request(url, options = {}) {
|
|
|
178
181
|
return JSON.stringify(body);
|
|
179
182
|
case 'application/x-www-form-urlencoded':
|
|
180
183
|
return (body instanceof URLSearchParams ? body : new URLSearchParams(body)).toString();
|
|
181
|
-
case 'multipart/form-data':
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
let value = body[key];
|
|
188
|
-
form.set(key, value);
|
|
189
|
-
}
|
|
190
|
-
return form;
|
|
191
|
-
}
|
|
184
|
+
case 'multipart/form-data': {
|
|
185
|
+
let form = new UndiciFormData();
|
|
186
|
+
for (const key in body)
|
|
187
|
+
form.set(key, body[key]);
|
|
188
|
+
return form;
|
|
189
|
+
}
|
|
192
190
|
}
|
|
193
|
-
})()
|
|
191
|
+
})()
|
|
194
192
|
};
|
|
195
193
|
let response;
|
|
196
194
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xshell",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.47",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"bin": {
|
|
@@ -49,17 +49,17 @@
|
|
|
49
49
|
]
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@babel/core": "^7.27.
|
|
53
|
-
"@babel/parser": "^7.27.
|
|
54
|
-
"@babel/traverse": "^7.27.
|
|
52
|
+
"@babel/core": "^7.27.4",
|
|
53
|
+
"@babel/parser": "^7.27.5",
|
|
54
|
+
"@babel/traverse": "^7.27.4",
|
|
55
55
|
"@koa/cors": "^5.0.0",
|
|
56
|
-
"@stylistic/eslint-plugin": "^4.4.
|
|
56
|
+
"@stylistic/eslint-plugin": "^4.4.1",
|
|
57
57
|
"@svgr/webpack": "^8.1.0",
|
|
58
58
|
"@types/sass-loader": "^8.0.9",
|
|
59
59
|
"@types/ws": "^8.18.1",
|
|
60
|
-
"@typescript-eslint/eslint-plugin": "^8.33.
|
|
61
|
-
"@typescript-eslint/parser": "^8.33.
|
|
62
|
-
"@typescript-eslint/utils": "^8.33.
|
|
60
|
+
"@typescript-eslint/eslint-plugin": "^8.33.1",
|
|
61
|
+
"@typescript-eslint/parser": "^8.33.1",
|
|
62
|
+
"@typescript-eslint/utils": "^8.33.1",
|
|
63
63
|
"archiver": "^7.0.1",
|
|
64
64
|
"chalk": "^5.4.1",
|
|
65
65
|
"cli-table3": "^0.6.5",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"commander": "^14.0.0",
|
|
68
68
|
"css-loader": "^7.1.2",
|
|
69
69
|
"emoji-regex": "^10.4.0",
|
|
70
|
-
"eslint": "^9.
|
|
70
|
+
"eslint": "^9.28.0",
|
|
71
71
|
"eslint-plugin-import": "^2.31.0",
|
|
72
72
|
"eslint-plugin-react": "^7.37.5",
|
|
73
73
|
"gulp-sort": "^2.0.0",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"react-i18next": "^15.5.2",
|
|
85
85
|
"react-object-model": "^1.2.24",
|
|
86
86
|
"resolve-path": "^1.4.0",
|
|
87
|
-
"sass": "^1.89.
|
|
87
|
+
"sass": "^1.89.1",
|
|
88
88
|
"sass-loader": "^16.0.5",
|
|
89
89
|
"source-map-loader": "^5.0.0",
|
|
90
90
|
"strip-ansi": "^7.1.0",
|
|
@@ -96,14 +96,14 @@
|
|
|
96
96
|
"typescript": "^5.8.3",
|
|
97
97
|
"ua-parser-js": "^2.0.3",
|
|
98
98
|
"undici": "^7.10.0",
|
|
99
|
-
"vinyl": "^3.0.
|
|
100
|
-
"vinyl-fs": "^4.0.
|
|
99
|
+
"vinyl": "^3.0.1",
|
|
100
|
+
"vinyl-fs": "^4.0.2",
|
|
101
101
|
"webpack": "^5.99.9",
|
|
102
102
|
"webpack-bundle-analyzer": "^4.10.2",
|
|
103
103
|
"ws": "^8.18.2"
|
|
104
104
|
},
|
|
105
105
|
"devDependencies": {
|
|
106
|
-
"@babel/types": "^7.27.
|
|
106
|
+
"@babel/types": "^7.27.6",
|
|
107
107
|
"@types/archiver": "^6.0.3",
|
|
108
108
|
"@types/babel__traverse": "^7.20.7",
|
|
109
109
|
"@types/eslint": "^9.6.1",
|
|
@@ -111,8 +111,8 @@
|
|
|
111
111
|
"@types/gulp-sort": "^2.0.4",
|
|
112
112
|
"@types/koa": "^2.15.0",
|
|
113
113
|
"@types/koa-compress": "^4.0.6",
|
|
114
|
-
"@types/mime-types": "^
|
|
115
|
-
"@types/node": "^22.15.
|
|
114
|
+
"@types/mime-types": "^3.0.0",
|
|
115
|
+
"@types/node": "^22.15.30",
|
|
116
116
|
"@types/react": "^19.1.6",
|
|
117
117
|
"@types/through2": "^2.0.41",
|
|
118
118
|
"@types/tough-cookie": "^4.0.5",
|