xshell 1.0.56 → 1.0.58

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
@@ -47,6 +47,7 @@ export interface RequestOptions {
47
47
  timeout?: number;
48
48
  auth?: BasicAuth | BearerAuth;
49
49
  cookies?: Record<string, string>;
50
+ redirect?: RequestRedirect;
50
51
  }
51
52
  export interface RequestRawOptions extends RequestOptions {
52
53
  raw: true;
package/net.js CHANGED
@@ -70,7 +70,7 @@ async function fetch_retry(url, options, timeout, retries = 0, count = 0) {
70
70
  }
71
71
  }
72
72
  }
73
- export async function request(url, { method, queries, headers: _headers, body, type = 'application/json', proxy, encoding, retries, timeout = 5 * 1000, auth, cookies: _cookies, raw = false, } = {}) {
73
+ export async function request(url, { method, queries, headers: _headers, body, type = 'application/json', proxy, encoding, retries, timeout = 5 * 1000, auth, cookies: _cookies, raw = false, redirect = 'follow', } = {}) {
74
74
  const { Headers, ProxyAgent, FormData } = await import('undici');
75
75
  url = new URL(url);
76
76
  if (queries)
@@ -121,7 +121,7 @@ export async function request(url, { method, queries, headers: _headers, body, t
121
121
  }
122
122
  })(),
123
123
  keepalive: true,
124
- redirect: 'follow',
124
+ redirect,
125
125
  maxRedirect: 6,
126
126
  credentials: 'include',
127
127
  headers,
@@ -158,7 +158,7 @@ export async function request(url, { method, queries, headers: _headers, body, t
158
158
  let response;
159
159
  try {
160
160
  response = await fetch_retry(url, options, timeout, retries);
161
- if (!response.ok)
161
+ if (!(response.ok || (redirect === 'manual' && 300 <= response.status && response.status < 400)))
162
162
  throw Object.assign(new Error(t('状态码 {{status}} 非 2xx', { status: response.status })), { name: 'StatusCodeError' });
163
163
  }
164
164
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.0.56",
3
+ "version": "1.0.58",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -16,8 +16,8 @@
16
16
  "interactive programming"
17
17
  ],
18
18
  "engines": {
19
- "node": ">=20.5.1",
20
- "vscode": ">=1.79.0"
19
+ "node": ">=20.6.0",
20
+ "vscode": ">=1.81.0"
21
21
  },
22
22
  "author": "ShenHongFei <shen.hongfei@outlook.com> (https://github.com/ShenHongFei)",
23
23
  "publisher": "ShenHongFei",
@@ -45,9 +45,9 @@
45
45
  ]
46
46
  },
47
47
  "dependencies": {
48
- "@babel/core": "^7.22.11",
49
- "@babel/parser": "^7.22.11",
50
- "@babel/traverse": "^7.22.11",
48
+ "@babel/core": "^7.22.15",
49
+ "@babel/parser": "^7.22.15",
50
+ "@babel/traverse": "^7.22.15",
51
51
  "@koa/cors": "^4.0.0",
52
52
  "@types/ws": "^8.5.5",
53
53
  "byte-size": "^8.1.1",
@@ -71,7 +71,7 @@
71
71
  "mime-types": "^2.1.35",
72
72
  "ora": "^7.0.1",
73
73
  "react": "^18.2.0",
74
- "react-i18next": "^13.2.0",
74
+ "react-i18next": "^13.2.2",
75
75
  "resolve-path": "^1.4.0",
76
76
  "strip-ansi": "^7.1.0",
77
77
  "through2": "^4.0.2",
@@ -85,7 +85,7 @@
85
85
  "ws": "^8.13.0"
86
86
  },
87
87
  "devDependencies": {
88
- "@babel/types": "^7.22.11",
88
+ "@babel/types": "^7.22.15",
89
89
  "@types/babel__traverse": "^7.20.1",
90
90
  "@types/byte-size": "^8.1.0",
91
91
  "@types/chardet": "^0.8.1",
@@ -95,15 +95,15 @@
95
95
  "@types/koa-compress": "^4.0.3",
96
96
  "@types/lodash": "^4.14.197",
97
97
  "@types/mime-types": "^2.1.1",
98
- "@types/node": "^20.5.7",
98
+ "@types/node": "^20.5.9",
99
99
  "@types/react": "^18.2.21",
100
100
  "@types/through2": "^2.0.38",
101
101
  "@types/tough-cookie": "^4.0.2",
102
- "@types/ua-parser-js": "^0.7.36",
102
+ "@types/ua-parser-js": "^0.7.37",
103
103
  "@types/vinyl-fs": "^3.0.2",
104
104
  "@types/vscode": "^1.81.0",
105
- "@typescript-eslint/eslint-plugin": "^6.4.1",
106
- "@typescript-eslint/parser": "^6.4.1",
105
+ "@typescript-eslint/eslint-plugin": "^6.6.0",
106
+ "@typescript-eslint/parser": "^6.6.0",
107
107
  "eslint": "^8.48.0",
108
108
  "eslint-plugin-react": "^7.33.2",
109
109
  "eslint-plugin-xlint": "^1.0.8"
package/server.d.ts CHANGED
@@ -16,7 +16,7 @@ declare module 'koa' {
16
16
  compress: boolean;
17
17
  }
18
18
  }
19
- import { type Remote, type Headers } from './net.js';
19
+ import { type Remote, type Headers, type RequestOptions } from './net.js';
20
20
  declare module 'http' {
21
21
  interface IncomingMessage {
22
22
  body?: Buffer;
@@ -66,7 +66,7 @@ export declare class Server {
66
66
  logger(ctx: Context): void;
67
67
  process_ua(ctx: Context): string;
68
68
  format_ua(headers: IncomingHttpHeaders | IncomingHttp2Headers): string;
69
- proxy(ctx: Context, url: string | URL, headers_?: Record<string, string>): Promise<void>;
69
+ proxy(ctx: Context, url: string | URL, headers_?: Record<string, string>, redirect?: RequestOptions['redirect']): Promise<void>;
70
70
  static filter_response_headers(headers: Headers): {};
71
71
  try_send(ctx: Context, fpd_root: string, fp: string, log_404: boolean): Promise<boolean>;
72
72
  /** 将 body 设置为 fp 所指文件的 ReadStream
package/server.js CHANGED
@@ -262,7 +262,7 @@ export class Server {
262
262
  }
263
263
  return s;
264
264
  }
265
- async proxy(ctx, url, headers_ = {}) {
265
+ async proxy(ctx, url, headers_ = {}, redirect = 'manual') {
266
266
  const { request: { method, headers, query, body, ip } } = ctx;
267
267
  let { response } = ctx;
268
268
  try {
@@ -276,6 +276,7 @@ export class Server {
276
276
  ...headers_
277
277
  },
278
278
  raw: true,
279
+ redirect,
279
280
  });
280
281
  response.status = response_.status;
281
282
  response.set(Server.filter_response_headers(response_.headers));