xshell 1.4.2 → 1.4.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.
package/net.d.ts CHANGED
@@ -42,7 +42,6 @@ export interface RequestOptions {
42
42
  retries?: true | number;
43
43
  timeout?: number;
44
44
  auth?: BasicAuth | BearerAuth;
45
- cookies?: Record<string, string>;
46
45
  redirect?: 'follow' | 'manual';
47
46
  decode?: boolean;
48
47
  dryrun?: boolean;
@@ -94,7 +93,6 @@ export declare class StatusCodeError extends Error {
94
93
  - retries?: `false` 可以传入 true (默认 2 次) 或 重试次数
95
94
  - timeout?: `5 * 1000` 超时后会抛出 error.name 为 'TimeoutError' 的 error (但类型不是 utils.ts 中的 TimeoutError), 可以传入 0 来禁用超时
96
95
  - auth?: BasicAuth | BearerAuth
97
- - cookies?: 需要额外添加到请求的 cookies, 默认情况下携带了 MemoryCookieStore 中保存的之前 http 响应中的 cookies
98
96
  - raw?: `false` 传入后返回整个 response (RawResponse),body 为 Readable
99
97
  - full?: `false` 传入后返回整个 response (FullResponse),body 根据 encoding 对应为 string 或 Buffer
100
98
  - decode?: `true` 根据 content-encoding: br 等解码压缩后的 response.body
package/net.js CHANGED
@@ -3,7 +3,7 @@ import net from 'node:net';
3
3
  import { buffer as stream_to_buffer, text as stream_to_text } from 'node:stream/consumers';
4
4
  import { pipeline, isReadable } from 'node:stream';
5
5
  import { noop } from './prototype.js';
6
- import { inspect, assert, delay, map_values, unique, timeout, check, colored, encode, TimeoutError, set_error_message, defer2, nowstr } from './utils.js';
6
+ import { inspect, assert, delay, map_values, timeout, check, colored, encode, TimeoutError, set_error_message, defer2, nowstr } from './utils.js';
7
7
  import { drop_request_headers } from './net.common.js';
8
8
  export * from './net.common.js';
9
9
  export const MyProxy = {
@@ -70,9 +70,8 @@ export class StatusCodeError extends Error {
70
70
  }
71
71
  export async function request(url, options = {}) {
72
72
  undici ??= (await import('undici')).default;
73
- const { Cookie } = await import('tough-cookie');
74
73
  await cookies.init();
75
- const { queries, headers: _headers, body, type = 'application/json', timeout = 5 * 1000, auth, cookies: _cookies, raw = false, full = false, redirect = 'follow', decode = true, dryrun, ua, browser: browser_ua, signal, print = {
74
+ const { queries, headers: _headers, body, type = 'application/json', timeout = 5 * 1000, auth, raw = false, full = false, redirect = 'follow', decode = true, dryrun, ua, browser: browser_ua, signal, print = {
76
75
  timeout: true,
77
76
  retry: true
78
77
  } } = options;
@@ -114,16 +113,6 @@ export async function request(url, options = {}) {
114
113
  `Basic ${`${auth.username}:${auth.password}`.to_base64()}`
115
114
  :
116
115
  `Bearer ${auth.token}`;
117
- const request_cookies = unique([
118
- ...cookies.jar.getCookiesSync(urlstr),
119
- ..._cookies ?
120
- Object.entries(_cookies).map(([key, value]) => new Cookie({ key, value }))
121
- :
122
- []
123
- ], 'key');
124
- if (request_cookies.length)
125
- headers.cookie = request_cookies.map(cookie => cookie.cookieString())
126
- .join('; ');
127
116
  if (_headers) {
128
117
  check(Object.getPrototypeOf(_headers)?.constructor.name !== 'Headers');
129
118
  for (const key in _headers)
@@ -155,11 +144,6 @@ export async function request(url, options = {}) {
155
144
  let response;
156
145
  try {
157
146
  const { statusCode: status, headers: _headers, body: _body } = await request_retry(url, undici_options, timeout, retries, 0, print);
158
- // 处理 cookie,自动保存到 cookie jar
159
- let _cookies = _headers['set-cookie'] || [];
160
- if (typeof _cookies === 'string')
161
- _cookies = [_cookies];
162
- _cookies.map(cookie => cookies.jar.setCookieSync(cookie, urlstr, { ignoreError: true }));
163
147
  const headers = map_values(_headers, value => Array.isArray(value) ? value.join(', ') : (value || ''));
164
148
  // UndiciResponse.body 没有自动根据 content-encoding 来解码,这里手动处理并替换 body 为解码后的 stream
165
149
  let body = _body;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -79,7 +79,6 @@
79
79
  "rollup-plugin-visualizer": "^7.0.1",
80
80
  "sass": "^1.101.0",
81
81
  "strip-ansi": "^7.2.0",
82
- "tough-cookie": "^6.0.1",
83
82
  "typescript": "^6.0.3",
84
83
  "undici": "^8.5.0",
85
84
  "ws": "^8.21.0"